Zelda Classic Coverage Report


Directory: src/
File: src/zc/zc_sys.cpp
Date: 2023-03-01 21:18:50
Exec Total Coverage
Lines: 1777 3986 44.6%
Functions: 128 341 37.5%
Branches: 948 2696 35.2%

Line Branch Exec Source
1 //--------------------------------------------------------
2 // Zelda Classic
3 // by Jeremy Craner, 1999-2000
4 //
5 // zc_sys.cc
6 //
7 // System functions, input handlers, GUI stuff, etc.
8 // for Zelda Classic.
9 //
10 //--------------------------------------------------------
11
12 // to prevent <map> from generating errors
13 #define __GTHREAD_HIDE_WIN32API 1
14
15 #include "precompiled.h" //always first
16 #include "zc_sys.h"
17
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29
18 #include <stdio.h>
19 #include <stdlib.h>
20 #include <string.h>
21 #include <math.h>
22 #include <map>
23 #include <filesystem>
24 #include <ctype.h>
25 #include <sstream>
26 #include "base/zc_alleg.h"
27 #include "gamedata.h"
28 #include "zc_init.h"
29 #include "init.h"
30 #include "replay.h"
31 #include "cheats.h"
32 #include "render.h"
33 #include "base/zc_math.h"
34 #include "base/zapp.h"
35 #include "dialog/cheatkeys.h"
36
37 #ifdef ALLEGRO_DOS
38 #include <unistd.h>
39 #endif
40
41 #include "metadata/metadata.h"
42 #include "zelda.h"
43 #include "tiles.h"
44 #include "base/colors.h"
45 #include "pal.h"
46 #include "base/zsys.h"
47 #include "qst.h"
48 #include "zc_sys.h"
49 #include "play_midi.h"
50 #include "debug.h"
51 #include "jwin_a5.h"
52 #include "base/jwinfsel.h"
53 #include "base/gui.h"
54 #include "midi.h"
55 #include "subscr.h"
56 #include "maps.h"
57 #include "sprite.h"
58 #include "guys.h"
59 #include "hero.h"
60 #include "title.h"
61 #include "particles.h"
62 #include "zconsole.h"
63 #include "ffscript.h"
64 #include "dialog/info.h"
65 #include "dialog/alert.h"
66 #include <fmt/format.h>
67
68 #ifdef __EMSCRIPTEN__
69 #include "base/emscripten_utils.h"
70 #endif
71
72 extern FFScript FFCore;
73 extern bool Playing;
74 int32_t sfx_voice[WAV_COUNT];
75 int32_t d_stringloader(int32_t msg,DIALOG *d,int32_t c);
76 int32_t d_midilist_proc(int32_t msg,DIALOG *d,int32_t c);
77
78 extern byte monochrome_console;
79
80 extern FONT *lfont;
81 extern HeroClass Hero;
82 extern FFScript FFCore;
83 extern ZModule zcm;
84 extern zcmodule moduledata;
85 extern sprite_list guys, items, Ewpns, Lwpns, Sitems, chainlinks, decorations;
86 extern particle_list particles;
87 extern int32_t loadlast;
88 extern word passive_subscreen_doscript;
89 extern bool passive_subscreen_waitdraw;
90 byte use_dwm_flush;
91 byte use_save_indicator;
92 byte midi_patch_fix;
93 bool midi_paused=false;
94 int32_t paused_midi_pos = 0;
95 byte midi_suspended = 0;
96 byte callback_switchin = 0;
97 byte zc_192b163_warp_compatibility;
98 char modulepath[2048];
99 bool epilepsyFlashReduction;
100 signed char pause_in_background_menu_init = 0;
101 byte pause_in_background = 0;
102 bool is_sys_pal = false;
103 static bool load_control_called_this_frame;
104 extern PALETTE* hw_palette;
105 extern bool update_hw_pal;
106 extern const char* dmaplist(int32_t index, int32_t* list_size);
107 int32_t getnumber(const char *prompt,int32_t initialval);
108
109 extern bool kb_typing_mode; //script only, for disbaling key presses affecting Hero, etc.
110 extern int32_t cheat_modifier_keys[4]; //two options each, default either control and either shift
111 //extern byte refresh_select_screen;
112 //extern movingblock mblock2; //mblock[4]?
113 //extern int32_t db;
114
115 static const char *ZC_str = "Zelda Classic";
116 extern char save_file_name[1024];
117 #ifdef ALLEGRO_DOS
118 const char *qst_dir_name = "dos_qst_dir";
119 #elif defined(ALLEGRO_WINDOWS)
120 const char *qst_dir_name = "win_qst_dir";
121 static const char *qst_module_name = "current_module";
122 #elif defined(ALLEGRO_LINUX)
123 const char *qst_dir_name = "linux_qst_dir";
124 static const char *qst_module_name = "current_module";
125 #elif defined(__APPLE__)
126 const char *qst_dir_name = "osx_qst_dir";
127 static const char *qst_module_name = "current_module";
128 #endif
129 #ifdef ALLEGRO_LINUX
130 static const char *samplepath = "samplesoundset/patches.dat";
131 #endif
132 char qst_files_path[2048];
133
134 #ifdef _MSC_VER
135 #define getcwd _getcwd
136 #endif
137
138 bool rF11();
139 bool rI();
140 bool rQ();
141 bool zc_key_pressed();
142
143 #ifdef _WIN32
144
145 // This should only be necessary for MinGW, since it doesn't have a dwmapi.h. Add another #ifdef if you like.
146 extern "C"
147 {
148 typedef HRESULT(WINAPI *t_DwmFlush)();
149 typedef HRESULT(WINAPI *t_DwmIsCompositionEnabled)(BOOL *pfEnabled);
150 }
151
152 void do_DwmFlush()
153 {
154 static HMODULE shell = LoadLibrary("dwmapi.dll");
155
156 if(!shell)
157 return;
158
159 static t_DwmFlush flush=reinterpret_cast<t_DwmFlush>(GetProcAddress(shell, "DwmFlush"));
160 static t_DwmIsCompositionEnabled isEnabled=reinterpret_cast<t_DwmIsCompositionEnabled>(GetProcAddress(shell, "DwmIsCompositionEnabled"));
161
162 BOOL enabled;
163 isEnabled(&enabled);
164
165 if(isEnabled)
166 flush();
167 }
168
169 #endif // _WIN32
170
171 82019 bool flash_reduction_enabled(bool check_qr)
172 {
173
4/4
✓ Branch 0 taken 79798 times.
✓ Branch 1 taken 2221 times.
✓ Branch 2 taken 79342 times.
✓ Branch 3 taken 81563 times.
82019 return (check_qr && get_bit(quest_rules, qr_EPILEPSY)) || epilepsyFlashReduction || replay_is_debug();
174 }
175
176 // Dialogue largening
177 void large_dialog(DIALOG *d)
178 {
179 large_dialog(d, 1.5);
180 }
181
182 void large_dialog(DIALOG *d, float RESIZE_AMT)
183 {
184 if(!d[0].d1)
185 {
186 d[0].d1 = 1;
187 int32_t oldwidth = d[0].w;
188 int32_t oldheight = d[0].h;
189 int32_t oldx = d[0].x;
190 int32_t oldy = d[0].y;
191 d[0].x -= int32_t(d[0].w/RESIZE_AMT);
192 d[0].y -= int32_t(d[0].h/RESIZE_AMT);
193 d[0].w = int32_t(d[0].w*RESIZE_AMT);
194 d[0].h = int32_t(d[0].h*RESIZE_AMT);
195
196 for(int32_t i=1; d[i].proc !=NULL; i++)
197 {
198 // Place elements horizontally
199 double xpc = ((double)(d[i].x - oldx) / (double)oldwidth);
200 d[i].x = int32_t(d[0].x + (xpc*d[0].w));
201
202 if(d[i].proc != d_stringloader)
203 {
204 if(d[i].proc==d_bitmap_proc)
205 {
206 d[i].w *= 2;
207 }
208 else d[i].w = int32_t(d[i].w*RESIZE_AMT);
209 }
210
211 // Place elements vertically
212 double ypc = ((double)(d[i].y - oldy) / (double)oldheight);
213 d[i].y = int32_t(d[0].y + (ypc*d[0].h));
214
215 // Vertically resize elements
216 if(d[i].proc == jwin_edit_proc || d[i].proc == jwin_check_proc || d[i].proc == jwin_checkfont_proc)
217 {
218 d[i].h = int32_t((double)d[i].h*1.5);
219 }
220 else if(d[i].proc == jwin_droplist_proc)
221 {
222 d[i].y += int32_t((double)d[i].h*0.25);
223 d[i].h = int32_t((double)d[i].h*1.25);
224 }
225 else if(d[i].proc==d_bitmap_proc)
226 {
227 d[i].h *= 2;
228 }
229 else d[i].h = int32_t(d[i].h*RESIZE_AMT);
230
231 // Fix frames
232 if(d[i].proc == jwin_frame_proc)
233 {
234 d[i].x++;
235 d[i].y++;
236 d[i].w-=4;
237 d[i].h-=4;
238 }
239 }
240 }
241
242 for(int32_t i=1; d[i].proc!=NULL; i++)
243 {
244 if(d[i].proc==jwin_slider_proc)
245 continue;
246
247 // Bigger font
248 auto& proc = d[i].proc;
249 bool bigfontproc = (proc != d_midilist_proc && proc != jwin_droplist_proc && proc != jwin_abclist_proc && proc != jwin_list_proc);
250 bool a5proc = (proc == jwin_win_proc_a5 || proc == jwin_tab_proc_a5 || proc == jwin_text_proc_a5 || proc == jwin_ctext_proc_a5 || proc == jwin_rtext_proc_a5 || proc == new_text_proc_a5 || proc == jwin_button_proc_a5
251 || proc == jwin_selcolor_proc_a5 || proc == jwin_color_swatch_a5);
252
253 if(!d[i].dp2 && bigfontproc)
254 {
255 d[i].dp2 = a5proc ? (void*)get_custom_font_a5(CFONT_DLG) : (void*)get_custom_font(CFONT_DLG);
256 }
257 else if(!bigfontproc)
258 {
259 ((ListData *)d[i].dp)->font = &lfont_l;
260 ((ListData *)d[i].dp)->a5font = &a5fonts[font_lfont_l];
261 }
262
263 // Make checkboxes work
264 if(d[i].proc == jwin_check_proc)
265 d[i].proc = jwin_checkfont_proc;
266 else if(d[i].proc == jwin_radio_proc)
267 d[i].proc = jwin_radiofont_proc;
268 else if(d[i].proc == jwin_radio_proc_a5)
269 d[i].proc = jwin_radiofont_proc_a5;
270 }
271
272 jwin_center_dialog(d);
273 }
274
275
276 /**********************************/
277 /******** System functions ********/
278 /**********************************/
279
280 static char cfg_sect[] = "zeldadx"; //We need to rename this.
281 static char ctrl_sect[] = "Controls";
282 static char sfx_sect[] = "Volume";
283
284 int32_t d_dummy_proc(int32_t,DIALOG *,int32_t)
285 {
286 return D_O_K;
287 }
288
289 bool checkcheat(Cheat cheat)
290 {
291 if(cheatkeys[cheat][0] && zc_readkey(cheatkeys[cheat][0]))
292 return true; //Main key pressed
293 if(cheatkeys[cheat][1] && zc_readkey(cheatkeys[cheat][1]))
294 return true; //Alt key pressed
295 return false;
296 }
297 29 void load_default_cheatkeys()
298 {
299 29 memset(cheatkeys, 0, sizeof(cheatkeys));
300 29 cheatkeys[Cheat::Life][0] = KEY_H;
301 29 cheatkeys[Cheat::Life][1] = KEY_ASTERISK;
302 29 cheatkeys[Cheat::Magic][0] = KEY_M;
303 29 cheatkeys[Cheat::Magic][1] = KEY_SLASH_PAD;
304 29 cheatkeys[Cheat::Rupies][0] = KEY_R;
305 29 cheatkeys[Cheat::Bombs][0] = KEY_B;
306 29 cheatkeys[Cheat::Arrows][0] = KEY_A;
307 29 cheatkeys[Cheat::Clock][0] = KEY_I;
308 29 cheatkeys[Cheat::Walls][0] = KEY_F11;
309 29 cheatkeys[Cheat::Fast][0] = KEY_Q;
310 29 cheatkeys[Cheat::Light][0] = KEY_L;
311 29 cheatkeys[Cheat::IgnoreSideView][0] = KEY_V;
312 29 cheatkeys[Cheat::Kill][0] = KEY_K;
313 29 cheatkeys[Cheat::GoTo][0] = KEY_G;
314 29 cheatkeys[Cheat::TrigSecrets][0] = KEY_S;
315 29 cheatkeys[Cheat::ShowL0][0] = KEY_0;
316 29 cheatkeys[Cheat::ShowL1][0] = KEY_1;
317 29 cheatkeys[Cheat::ShowL2][0] = KEY_2;
318 29 cheatkeys[Cheat::ShowL3][0] = KEY_3;
319 29 cheatkeys[Cheat::ShowL4][0] = KEY_4;
320 29 cheatkeys[Cheat::ShowL5][0] = KEY_5;
321 29 cheatkeys[Cheat::ShowL6][0] = KEY_6;
322 29 cheatkeys[Cheat::ShowFFC][0] = KEY_7;
323 29 cheatkeys[Cheat::ShowSprites][0] = KEY_8;
324 29 cheatkeys[Cheat::ShowWalkability][0] = KEY_W;
325 29 cheatkeys[Cheat::ShowEffects][0] = KEY_E;
326 29 cheatkeys[Cheat::ShowOverhead][0] = KEY_O;
327 29 cheatkeys[Cheat::ShowPushblock][0] = KEY_P;
328 29 cheatkeys[Cheat::ShowHitbox][0] = KEY_C;
329 29 cheatkeys[Cheat::ShowFFCScripts][0] = KEY_F;
330 29 }
331 29 void load_game_configs()
332 {
333 29 strcpy(moduledata.module_name,zc_get_config("ZCMODULE",qst_module_name,"classic.zmod"));
334 29 joystick_index = zc_get_config(ctrl_sect,"joystick_index",0);
335 29 js_stick_1_x_stick = zc_get_config(ctrl_sect,"js_stick_1_x_stick",0);
336 29 js_stick_1_x_axis = zc_get_config(ctrl_sect,"js_stick_1_x_axis",0);
337 29 js_stick_1_x_offset = zc_get_config(ctrl_sect,"js_stick_1_x_offset",0) ? 128 : 0;
338 29 js_stick_1_y_stick = zc_get_config(ctrl_sect,"js_stick_1_y_stick",0);
339 29 js_stick_1_y_axis = zc_get_config(ctrl_sect,"js_stick_1_y_axis",1);
340 29 js_stick_1_y_offset = zc_get_config(ctrl_sect,"js_stick_1_y_offset",0) ? 128 : 0;
341 29 js_stick_2_x_stick = zc_get_config(ctrl_sect,"js_stick_2_x_stick",1);
342 29 js_stick_2_x_axis = zc_get_config(ctrl_sect,"js_stick_2_x_axis",0);
343 29 js_stick_2_x_offset = zc_get_config(ctrl_sect,"js_stick_2_x_offset",0) ? 128 : 0;
344 29 js_stick_2_y_stick = zc_get_config(ctrl_sect,"js_stick_2_y_stick",1);
345 29 js_stick_2_y_axis = zc_get_config(ctrl_sect,"js_stick_2_y_axis",1);
346 29 js_stick_2_y_offset = zc_get_config(ctrl_sect,"js_stick_2_y_offset",0) ? 128 : 0;
347 29 analog_movement = (zc_get_config(ctrl_sect,"analog_movement",1));
348
349 //cheat modifier keya
350 29 cheat_modifier_keys[0] = zc_get_config(ctrl_sect,"key_cheatmod_a1",KEY_ZC_LCONTROL);
351 29 cheat_modifier_keys[1] = zc_get_config(ctrl_sect,"key_cheatmod_a2",0);
352 29 cheat_modifier_keys[2] = zc_get_config(ctrl_sect,"key_cheatmod_b1",KEY_ZC_RCONTROL);
353 29 cheat_modifier_keys[3] = zc_get_config(ctrl_sect,"key_cheatmod_b2",0);
354
355 //cheat keys
356 29 load_default_cheatkeys();
357 char buf[256];
358 29 al_trace("START CHEATS\n");
359
2/2
✓ Branch 0 taken 1015 times.
✓ Branch 1 taken 29 times.
1044 for(size_t q = 1; q < Cheat::Last; ++q)
360 {
361
1/2
✓ Branch 0 taken 1015 times.
✗ Branch 1 not taken.
1015 if(!bindable_cheat((Cheat)q)) continue;
362 1015 std::string cheatname = cheat_to_string((Cheat)q);
363
1/2
✓ Branch 0 taken 1015 times.
✗ Branch 1 not taken.
1015 util::lowerstr(cheatname);
364 1015 sprintf(buf, "key_cheat_%s_main", cheatname.c_str());
365
1/2
✓ Branch 0 taken 1015 times.
✗ Branch 1 not taken.
1015 al_trace("%s = %d\n", buf, cheatkeys[q][0]);
366
1/2
✓ Branch 0 taken 1015 times.
✗ Branch 1 not taken.
1015 cheatkeys[q][0] = zc_get_config(ctrl_sect,buf,cheatkeys[q][0]);
367 1015 sprintf(buf, "key_cheat_%s_alt", cheatname.c_str());
368
1/2
✓ Branch 0 taken 1015 times.
✗ Branch 1 not taken.
1015 al_trace("%s = %d\n", buf, cheatkeys[q][1]);
369
1/2
✓ Branch 0 taken 1015 times.
✗ Branch 1 not taken.
1015 cheatkeys[q][1] = zc_get_config(ctrl_sect,buf,cheatkeys[q][1]);
370 1015 }
371 29 al_trace("END CHEATS\n");
372
373
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 if((uint32_t)joystick_index >= MAX_JOYSTICKS)
374 joystick_index = 0;
375
376 29 Akey = zc_get_config(ctrl_sect,"key_a",KEY_Z);
377 29 Bkey = zc_get_config(ctrl_sect,"key_b",KEY_X);
378 29 Skey = zc_get_config(ctrl_sect,"key_s",KEY_ENTER);
379 29 Lkey = zc_get_config(ctrl_sect,"key_l",KEY_Q);
380 29 Rkey = zc_get_config(ctrl_sect,"key_r",KEY_W);
381 29 Pkey = zc_get_config(ctrl_sect,"key_p",KEY_SPACE);
382 29 Exkey1 = zc_get_config(ctrl_sect,"key_ex1",KEY_A);
383 29 Exkey2 = zc_get_config(ctrl_sect,"key_ex2",KEY_S);
384 29 Exkey3 = zc_get_config(ctrl_sect,"key_ex3",KEY_D);
385 29 Exkey4 = zc_get_config(ctrl_sect,"key_ex4",KEY_C);
386
387 29 DUkey = zc_get_config(ctrl_sect,"key_up", KEY_UP);
388 29 DDkey = zc_get_config(ctrl_sect,"key_down", KEY_DOWN);
389 29 DLkey = zc_get_config(ctrl_sect,"key_left", KEY_LEFT);
390 29 DRkey = zc_get_config(ctrl_sect,"key_right",KEY_RIGHT);
391
392 29 Abtn = zc_get_config(ctrl_sect,"btn_a",2);
393 29 Bbtn = zc_get_config(ctrl_sect,"btn_b",1);
394 29 Sbtn = zc_get_config(ctrl_sect,"btn_s",10);
395 29 Mbtn = zc_get_config(ctrl_sect,"btn_m",9);
396 29 Lbtn = zc_get_config(ctrl_sect,"btn_l",5);
397 29 Rbtn = zc_get_config(ctrl_sect,"btn_r",6);
398 29 Pbtn = zc_get_config(ctrl_sect,"btn_p",12);
399 29 Exbtn1 = zc_get_config(ctrl_sect,"btn_ex1",7);
400 29 Exbtn2 = zc_get_config(ctrl_sect,"btn_ex2",8);
401 29 Exbtn3 = zc_get_config(ctrl_sect,"btn_ex3",4);
402 29 Exbtn4 = zc_get_config(ctrl_sect,"btn_ex4",3);
403
404 29 DUbtn = zc_get_config(ctrl_sect,"btn_up",13);
405 29 DDbtn = zc_get_config(ctrl_sect,"btn_down",14);
406 29 DLbtn = zc_get_config(ctrl_sect,"btn_left",15);
407 29 DRbtn = zc_get_config(ctrl_sect,"btn_right",16);
408
409 29 epilepsyFlashReduction = zc_get_config(cfg_sect,"epilepsy_flash_reduction",0);
410
411 29 digi_volume = zc_get_config(sfx_sect,"digi",248);
412 29 midi_volume = zc_get_config(sfx_sect,"midi",255);
413 29 sfx_volume = zc_get_config(sfx_sect,"sfx",248);
414 29 emusic_volume = zc_get_config(sfx_sect,"emusic",248);
415 29 pan_style = zc_get_config(sfx_sect,"pan",1);
416 // 1 <= zcmusic_bufsz <= 128
417 29 zcmusic_bufsz = vbound(zc_get_config(sfx_sect,"zcmusic_bufsz",64),1,128);
418 29 volkeys = zc_get_config(sfx_sect,"volkeys",0)!=0;
419 29 zc_vsync = zc_get_config(cfg_sect,"vsync",0);
420 29 Throttlefps = zc_get_config(cfg_sect,"throttlefps",1)!=0;
421 29 TransLayers = zc_get_config(cfg_sect,"translayers",1)!=0;
422 29 SnapshotFormat = zc_get_config(cfg_sect,"snapshot_format",3);
423 29 NameEntryMode = zc_get_config(cfg_sect,"name_entry_mode",0);
424 #ifdef __EMSCRIPTEN__
425 if (em_is_mobile()) NameEntryMode = 2;
426 #endif
427 29 ShowFPS = zc_get_config(cfg_sect,"showfps",0)!=0;
428 29 NESquit = zc_get_config(cfg_sect,"fastquit",0)!=0;
429 29 ClickToFreeze = zc_get_config(cfg_sect,"clicktofreeze",1)!=0;
430 29 title_version = zc_get_config(cfg_sect,"title",2);
431 29 abc_patternmatch = zc_get_config(cfg_sect, "lister_pattern_matching", 1);
432 29 pause_in_background = zc_get_config(cfg_sect, "pause_in_background", 0);
433
434 //default - scale x2, 640 x 480
435 29 window_width = resx = zc_get_config(cfg_sect,"window_width",640);
436 29 window_height = resy = zc_get_config(cfg_sect,"window_height",480);
437 29 SaveDragResize = zc_get_config(cfg_sect,"save_drag_resize",0)!=0;
438 29 DragAspect = zc_get_config(cfg_sect,"drag_aspect",0)!=0;
439 29 SaveWinPos = zc_get_config(cfg_sect,"save_window_position",0)!=0;
440
441 29 loadlast = zc_get_config(cfg_sect,"load_last",0);
442
443 29 fullscreen = zc_get_config(cfg_sect,"fullscreen",0);
444
445 29 zc_color_depth = (byte) zc_get_config(cfg_sect,"color_depth",8);
446
447 29 forceExit = (byte) zc_get_config(cfg_sect,"force_exit",0);
448 29 info_opacity = zc_get_config("zc","debug_info_opacity",255);
449 #ifdef _WIN32
450 zasm_debugger = (byte) zc_get_config("CONSOLE","print_ZASM",0);
451 zscript_debugger = (byte) zc_get_config("CONSOLE","ZScript_Debugger",0);
452 //use_win7_keyboard_fix = (byte) zc_get_config(cfg_sect,"use_win7_key_fix",0);
453 use_win32_proc = (byte) zc_get_config(cfg_sect,"zc_win_proc_fix",0); //buggy
454
455 // This one's for Aero
456 use_dwm_flush = (byte) zc_get_config("zeldadx","use_dwm_flush",0);
457
458 // And this one fixes patches unloading on some MIDI setups
459 midi_patch_fix = (byte) zc_get_config("zeldadx","midi_patch_fix",1);
460 monochrome_console = (byte) zc_get_config("CONSOLE","monochrome_debuggers",0);
461 #else //UNIX
462 29 zasm_debugger = (byte) zc_get_config("CONSOLE","print_ZASM",0);
463 29 zscript_debugger = (byte) zc_get_config("CONSOLE","ZScript_Debugger",0);
464 29 monochrome_console = (byte) zc_get_config("CONSOLE","monochrome_debuggers",0);
465 #endif
466 29 clearConsoleOnLoad = zc_get_config("CONSOLE","clear_console_on_load",1)!=0;
467
468 29 char const* default_path = "";
469 29 strcpy(qstdir,zc_get_config(cfg_sect,qst_dir_name,default_path));
470
471
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29 times.
29 if(strlen(qstdir)==0)
472 {
473 29 getcwd(qstdir,2048);
474 29 fix_filename_case(qstdir);
475 29 fix_filename_slashes(qstdir);
476 29 put_backslash(qstdir);
477 29 }
478 else
479 {
480 chop_path(qstdir);
481 }
482
483 29 strcpy(qstpath,qstdir); //qstpath is the local (for this run of ZC) quest path, qstdir is the universal quest dir.
484 29 ss_enable = zc_get_config(cfg_sect,"ss_enable",1) ? 1 : 0;
485 29 ss_after = vbound(zc_get_config(cfg_sect,"ss_after",14), 0, 14);
486 29 ss_speed = vbound(zc_get_config(cfg_sect,"ss_speed",2), 0, 6);
487 29 ss_density = vbound(zc_get_config(cfg_sect,"ss_density",3), 0, 6);
488 29 heart_beep = zc_get_config(cfg_sect,"heart_beep",1)!=0;
489 //gui_colorset = zc_get_config(cfg_sect,"gui_colorset",0);
490 29 sfxdat = zc_get_config(cfg_sect,"use_sfx_dat",1);
491 29 fullscreen = zc_get_config(cfg_sect,"fullscreen",0);
492 29 use_save_indicator = zc_get_config(cfg_sect,"save_indicator",0);
493 29 zc_192b163_warp_compatibility = zc_get_config(cfg_sect,"zc_192b163_warp_compatibility",0);
494 29 }
495
496 void save_control_configs(bool kb)
497 {
498 if(kb)
499 {
500 zc_set_config(ctrl_sect,"key_cheatmod_a1",cheat_modifier_keys[0]);
501 zc_set_config(ctrl_sect,"key_cheatmod_a2",cheat_modifier_keys[1]);
502 zc_set_config(ctrl_sect,"key_cheatmod_b1",cheat_modifier_keys[2]);
503 zc_set_config(ctrl_sect,"key_cheatmod_b2",cheat_modifier_keys[3]);
504
505 if (!replay_is_replaying())
506 {
507 zc_set_config(ctrl_sect,"key_a",Akey);
508 zc_set_config(ctrl_sect,"key_b",Bkey);
509 zc_set_config(ctrl_sect,"key_s",Skey);
510 zc_set_config(ctrl_sect,"key_l",Lkey);
511 zc_set_config(ctrl_sect,"key_r",Rkey);
512 zc_set_config(ctrl_sect,"key_p",Pkey);
513 zc_set_config(ctrl_sect,"key_ex1",Exkey1);
514 zc_set_config(ctrl_sect,"key_ex2",Exkey2);
515 zc_set_config(ctrl_sect,"key_ex3",Exkey3);
516 zc_set_config(ctrl_sect,"key_ex4",Exkey4);
517 zc_set_config(ctrl_sect,"key_up", DUkey);
518 zc_set_config(ctrl_sect,"key_down", DDkey);
519 zc_set_config(ctrl_sect,"key_left", DLkey);
520 zc_set_config(ctrl_sect,"key_right",DRkey);
521 }
522 }
523 else
524 {
525 zc_set_config(ctrl_sect,"joystick_index",joystick_index);
526 zc_set_config(ctrl_sect,"js_stick_1_x_stick",js_stick_1_x_stick);
527 zc_set_config(ctrl_sect,"js_stick_1_x_axis",js_stick_1_x_axis);
528 zc_set_config(ctrl_sect,"js_stick_1_x_offset",js_stick_1_x_offset ? 1 : 0);
529 zc_set_config(ctrl_sect,"js_stick_1_y_stick",js_stick_1_y_stick);
530 zc_set_config(ctrl_sect,"js_stick_1_y_axis",js_stick_1_y_axis);
531 zc_set_config(ctrl_sect,"js_stick_1_y_offset",js_stick_1_y_offset ? 1 : 0);
532 zc_set_config(ctrl_sect,"js_stick_2_x_stick",js_stick_2_x_stick);
533 zc_set_config(ctrl_sect,"js_stick_2_x_axis",js_stick_2_x_axis);
534 zc_set_config(ctrl_sect,"js_stick_2_x_offset",js_stick_2_x_offset ? 1 : 0);
535 zc_set_config(ctrl_sect,"js_stick_2_y_stick",js_stick_2_y_stick);
536 zc_set_config(ctrl_sect,"js_stick_2_y_axis",js_stick_2_y_axis);
537 zc_set_config(ctrl_sect,"js_stick_2_y_offset",js_stick_2_y_offset ? 1 : 0);
538 zc_set_config(ctrl_sect,"analog_movement",analog_movement);
539
540 zc_set_config(ctrl_sect,"btn_a",Abtn);
541 zc_set_config(ctrl_sect,"btn_b",Bbtn);
542 zc_set_config(ctrl_sect,"btn_s",Sbtn);
543 zc_set_config(ctrl_sect,"btn_m",Mbtn);
544 zc_set_config(ctrl_sect,"btn_l",Lbtn);
545 zc_set_config(ctrl_sect,"btn_r",Rbtn);
546 zc_set_config(ctrl_sect,"btn_p",Pbtn);
547 zc_set_config(ctrl_sect,"btn_ex1",Exbtn1);
548 zc_set_config(ctrl_sect,"btn_ex2",Exbtn2);
549 zc_set_config(ctrl_sect,"btn_ex3",Exbtn3);
550 zc_set_config(ctrl_sect,"btn_ex4",Exbtn4);
551
552 zc_set_config(ctrl_sect,"btn_up",DUbtn);
553 zc_set_config(ctrl_sect,"btn_down",DDbtn);
554 zc_set_config(ctrl_sect,"btn_left",DLbtn);
555 zc_set_config(ctrl_sect,"btn_right",DRbtn);
556 }
557 }
558
559 void save_cheatkeys()
560 {
561 char buf[256];
562 for(size_t q = 1; q < Cheat::Last; ++q)
563 {
564 if(!bindable_cheat((Cheat)q)) continue;
565 std::string cheatname = cheat_to_string((Cheat)q);
566 util::lowerstr(cheatname);
567 sprintf(buf, "key_cheat_%s_main", cheatname.c_str());
568 zc_set_config(ctrl_sect,buf,cheatkeys[q][0]);
569 sprintf(buf, "key_cheat_%s_alt", cheatname.c_str());
570 if(cheatkeys[q][1])
571 zc_set_config(ctrl_sect,buf,cheatkeys[q][1]);
572 else zc_set_config(ctrl_sect,buf,(char*)nullptr);
573 }
574 }
575
576 void save_game_configs()
577 {
578 packfile_password("");
579
580 zc_set_config("ZCMODULE",qst_module_name,moduledata.module_name);
581
582 if (all_get_display() && !all_get_fullscreen_flag()&& SaveWinPos)
583 {
584 int o_window_x, o_window_y;
585 al_get_window_position(all_get_display(), &o_window_x, &o_window_y);
586 zc_set_config(cfg_sect,"window_x",o_window_x);
587 zc_set_config(cfg_sect,"window_y",o_window_y);
588 }
589
590 if (all_get_display() && !all_get_fullscreen_flag() && SaveDragResize)
591 {
592 double monitor_scale = zc_get_monitor_scale();
593 window_width = al_get_display_width(all_get_display()) / monitor_scale;
594 window_height = al_get_display_height(all_get_display()) / monitor_scale;
595 zc_set_config(cfg_sect,"window_width",window_width);
596 zc_set_config(cfg_sect,"window_height",window_height);
597 }
598
599 zc_set_config(cfg_sect,"load_last",loadlast);
600 chop_path(qstdir);
601 zc_set_config(cfg_sect,qst_dir_name,qstdir);
602 zc_set_config("SAVEFILE","save_filename",save_file_name);
603 zc_set_config(cfg_sect,"use_sfx_dat",sfxdat);
604
605 flush_config_file();
606 #ifdef __EMSCRIPTEN__
607 em_sync_fs();
608 #endif
609 }
610
611 //----------------------------------------------------------------
612
613 // Timers
614
615 28089 void fps_callback()
616 {
617 28089 lastfps=framecnt;
618 28089 dword tempsecs = fps_secs;
619 28089 ++tempsecs;
620 //avgfps=((long double)avgfps*fps_secs+lastfps)/(++fps_secs); // DJGPP doesn't like this
621 28089 avgfps=((long double)avgfps*fps_secs+lastfps)/(tempsecs);
622 28089 ++fps_secs;
623 28089 framecnt=0;
624 28089 }
625
626 END_OF_FUNCTION(fps_callback)
627
628 29 int32_t Z_init_timers()
629 {
630 static bool didit = false;
631 const static char *err_str = "Couldn't allocate timer";
632 29 err_str = err_str; //Unused variable warning
633
634
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29 times.
29 if(didit)
635 return 1;
636
637 29 didit = true;
638
639 LOCK_VARIABLE(lastfps);
640 LOCK_VARIABLE(framecnt);
641 LOCK_FUNCTION(fps_callback);
642
643
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 if(install_int_ex(fps_callback,SECS_TO_TIMER(1)))
644 return 0;
645
646 29 return 1;
647 29 }
648
649 void Z_remove_timers()
650 {
651 remove_int(fps_callback);
652 }
653
654 //----------------------------------------------------------------
655
656 void go()
657 {
658 scare_mouse();
659 blit(screen,tmp_scr,scrx,scry,0,0,screen->w,screen->h);
660 unscare_mouse();
661 }
662
663 void comeback()
664 {
665 scare_mouse();
666 blit(tmp_scr,screen,0,0,scrx,scry,screen->w,screen->h);
667 unscare_mouse();
668 }
669
670 void dump_pal(BITMAP *dest)
671 {
672 for(int32_t i=0; i<256; i++)
673 rectfill(dest,(i&63)<<2,(i&0xFC0)>>4,((i&63)<<2)+3,((i&0xFC0)>>4)+3,i);
674 }
675
676 //----------------------------------------------------------------
677
678 //Handles converting the mouse sprite from the .dat file
679 29 void load_mouse()
680 {
681 29 system_pal();
682 29 scare_mouse();
683 29 set_mouse_sprite(NULL);
684 29 int32_t sz = vbound(int32_t(16*(zc_get_config("zeldadx","cursor_scale_large",1.5))),16,80);
685
2/2
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 29 times.
145 for(int32_t j = 0; j < 4; ++j)
686 {
687 116 BITMAP* tmpbmp = create_bitmap_ex(8,16,16);
688 116 BITMAP* subbmp = create_bitmap_ex(8,16,16);
689
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if(zcmouse[j])
690 destroy_bitmap(zcmouse[j]);
691 116 zcmouse[j] = create_bitmap_ex(8,sz,sz);
692 116 clear_bitmap(zcmouse[j]);
693 116 clear_bitmap(tmpbmp);
694 116 clear_bitmap(subbmp);
695 116 blit((BITMAP*)datafile[BMP_MOUSE].dat,tmpbmp,1,j*17+1,0,0,16,16);
696
2/2
✓ Branch 0 taken 1856 times.
✓ Branch 1 taken 116 times.
1972 for(int32_t x = 0; x < 16; ++x)
697 {
698
2/2
✓ Branch 0 taken 29696 times.
✓ Branch 1 taken 1856 times.
31552 for(int32_t y = 0; y < 16; ++y)
699 {
700 29696 int32_t color = getpixel(tmpbmp, x, y);
701
5/5
✓ Branch 0 taken 27318 times.
✓ Branch 1 taken 551 times.
✓ Branch 2 taken 638 times.
✓ Branch 3 taken 667 times.
✓ Branch 4 taken 522 times.
29696 switch(color)
702 {
703 case dvc(1):
704 551 color = jwin_pal[jcCURSORMISC];
705 551 break;
706 case dvc(2):
707 638 color = jwin_pal[jcCURSOROUTLINE];
708 638 break;
709 case dvc(3):
710 667 color = jwin_pal[jcCURSORLIGHT];
711 667 break;
712 case dvc(5):
713 522 color = jwin_pal[jcCURSORDARK];
714 522 break;
715 }
716 29696 putpixel(subbmp, x, y, color);
717 29696 }
718 1856 }
719
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if(sz!=16)
720 116 stretch_blit(subbmp, zcmouse[j], 0, 0, 16, 16, 0, 0, sz, sz);
721 else
722 blit(subbmp, zcmouse[j], 0, 0, 0, 0, 16, 16);
723 116 destroy_bitmap(tmpbmp);
724 116 destroy_bitmap(subbmp);
725 116 }
726 29 set_mouse_sprite(zcmouse[0]);
727
728 // Must attempt to show cursor for allegro 5 to render it with the associated palette.
729 29 set_palette(*hw_palette);
730 29 show_mouse(screen);
731 29 show_mouse(NULL);
732
733 29 unscare_mouse();
734 29 game_pal();
735 29 }
736
737 // sets the video mode and initializes the palette and mouse sprite
738 29 bool game_vid_mode(int32_t mode,int32_t wait)
739 {
740
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29 times.
29 if(set_gfx_mode(mode,resx,resy,0,0)!=0)
741 {
742 return false;
743 }
744
745 29 scrx = (resx-320)>>1;
746 29 scry = (resy-240)>>1;
747
2/2
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 29 times.
145 for(int32_t q = 0; q < 4; ++q)
748 116 zcmouse[q] = NULL;
749 29 load_mouse();
750 29 set_mouse_sprite(zcmouse[0]);
751
752
2/2
✓ Branch 0 taken 464 times.
✓ Branch 1 taken 29 times.
493 for(int32_t i=240; i<256; i++)
753 464 RAMpal[i]=((RGB*)datafile[PAL_GUI].dat)[i];
754
755 29 set_palette(RAMpal);
756 29 clear_to_color(screen,BLACK);
757
758 29 rest(wait);
759 29 return true;
760 29 }
761
762 5 void null_quest()
763 {
764 char qstdat_string[2048];
765 5 strcpy(qstdat_string,moduledata.datafiles[qst_dat]);
766 5 strcat(qstdat_string,"#NESQST_NEW_QST");
767
768 #ifdef __EMSCRIPTEN__
769 // The quest template data file is not included because it's really big and isn't really needed
770 // for the player, except to initialize some graphics. Those same graphics exist in this quest file,
771 // which is much smaller.
772 strcpy(qstdat_string, "modules/classic/title_gfx.dat");
773 #endif
774
775 5 byte skip_flags[4] = { 0 };
776
777 5 loadquest(qstdat_string,&QHeader,&QMisc,tunes+ZC_MIDI_COUNT,false,true,true,true,skip_flags,0,false);
778 5 }
779
780 5 void init_NES_mode()
781 {
782 /*
783 // qst.dat may not load correctly without this...
784 QHeader.templatepath[0]='\0';
785
786 if(!init_colordata(true, &QHeader, &QMisc))
787 {
788 return;
789 }
790
791 loadfullpal();
792 init_tiles(false, &QHeader);
793 */
794 5 null_quest();
795 5 }
796
797 //----------------------------------------------------------------
798
799 qword trianglelines[16]=
800 {
801 0x0000000000000000ULL,
802 0xFD00000000000000ULL,
803 0xFDFD000000000000ULL,
804 0xFDFDFD0000000000ULL,
805 0xFDFDFDFD00000000ULL,
806 0xFDFDFDFDFD000000ULL,
807 0xFDFDFDFDFDFD0000ULL,
808 0xFDFDFDFDFDFDFD00ULL,
809 0xFDFDFDFDFDFDFDFDULL,
810 0x00FDFDFDFDFDFDFDULL,
811 0x0000FDFDFDFDFDFDULL,
812 0x000000FDFDFDFDFDULL,
813 0x00000000FDFDFDFDULL,
814 0x0000000000FDFDFDULL,
815 0x000000000000FDFDULL,
816 0x00000000000000FDULL,
817 };
818
819 word screen_triangles[28][32];
820 /*
821 qword triangles[4][16]= //[direction][value]
822 {
823 {
824 0x00000000, 0x10000000, 0x21000000, 0x32100000, 0x43210000, 0x54321000, 0x65432100, 0x76543210, 0x87654321, 0x88765432, 0x88876543, 0x88887654, 0x88888765, 0x88888876, 0x88888887, 0x88888888
825 },
826 {
827 0x00000000, 0xF0000000, 0xEF000000, 0xFDF00000, 0xCFDF0000, 0xBCFDF000, 0xABCFDF00, 0x9ABCFDF0, 0x89ABCFDF, 0x889ABCFD, 0x8889ABCD, 0x88889ABC, 0x888889AB, 0x8888889A, 0x88888889, 0x88888888
828 },
829 {
830 0x00000000, 0x00000001, 0x00000012, 0x00000123, 0x00001234, 0x00012345, 0x00123456, 0x01234567, 0x12345678, 0x23456788, 0x34567888, 0x45678888, 0x56788888, 0x67888888, 0x78888888, 0x88888888
831 },
832 {
833 0x00000000, 0x0000000F, 0x000000FE, 0x00000FED, 0x0000FEDC, 0x000FEDCB, 0x00FEDCBA, 0x0FEDCBA9, 0xFEDCBA98, 0xEDCBA988, 0xDCBA9888, 0xCBA98888, 0xBA988888, 0xA9888888, 0x98888888, 0x88888888
834 }
835 };
836 */
837
838
839 /*
840 byte triangles[4][16][8]= //[direction][value][line]
841 {
842 {
843 {
844 0, 0, 0, 0, 0, 0, 0, 0
845 },
846 {
847 1, 0, 0, 0, 0, 0, 0, 0
848 },
849 {
850 2, 1, 0, 0, 0, 0, 0, 0
851 },
852 {
853 3, 2, 1, 0, 0, 0, 0, 0
854 },
855 {
856 4, 3, 2, 1, 0, 0, 0, 0
857 },
858 {
859 5, 4, 3, 2, 1, 0, 0, 0
860 },
861 {
862 6, 5, 4, 3, 2, 1, 0, 0
863 },
864 {
865 7, 6, 5, 4, 3, 2, 1, 0
866 },
867 {
868 8, 7, 6, 5, 4, 3, 2, 1
869 },
870 {
871 8, 8, 7, 6, 5, 4, 3, 2
872 },
873 {
874 8, 8, 8, 7, 6, 5, 4, 3
875 },
876 {
877 8, 8, 8, 8, 7, 6, 5, 4
878 },
879 {
880 8, 8, 8, 8, 8, 7, 6, 5
881 },
882 {
883 8, 8, 8, 8, 8, 8, 7, 6
884 },
885 {
886 8, 8, 8, 8, 8, 8, 8, 7
887 },
888 {
889 8, 8, 8, 8, 8, 8, 8, 8
890 }
891 },
892 {
893 {
894 0, 0, 0, 0, 0, 0, 0, 0
895 },
896 {
897 15, 0, 0, 0, 0, 0, 0, 0
898 },
899 {
900 14, 15, 0, 0, 0, 0, 0, 0
901 },
902 {
903 13, 14, 15, 0, 0, 0, 0, 0
904 },
905 {
906 12, 13, 14, 15, 0, 0, 0, 0
907 },
908 {
909 11, 12, 13, 14, 15, 0, 0, 0
910 },
911 {
912 10, 11, 12, 13, 14, 15, 0, 0
913 },
914 {
915 9, 10, 11, 12, 13, 14, 15, 0
916 },
917 {
918 8, 9, 10, 11, 12, 13, 14, 15
919 },
920 {
921 8, 8, 9, 10, 11, 12, 13, 14
922 },
923 {
924 8, 8, 8, 9, 10, 11, 12, 13
925 },
926 {
927 8, 8, 8, 8, 9, 10, 11, 12
928 },
929 {
930 8, 8, 8, 8, 8, 9, 10, 11
931 },
932 {
933 8, 8, 8, 8, 8, 8, 9, 10
934 },
935 {
936 8, 8, 8, 8, 8, 8, 8, 9
937 },
938 {
939 8, 8, 8, 8, 8, 8, 8, 8
940 }
941 },
942 {
943 {
944 0, 0, 0, 0, 0, 0, 0, 0
945 },
946 {
947 0, 0, 0, 0, 0, 0, 0, 1
948 },
949 {
950 0, 0, 0, 0, 0, 0, 1, 2
951 },
952 {
953 0, 0, 0, 0, 0, 1, 2, 3
954 },
955 {
956 0, 0, 0, 0, 1, 2, 3, 4
957 },
958 {
959 0, 0, 0, 1, 2, 3, 4, 5
960 },
961 {
962 0, 0, 1, 2, 3, 4, 5, 6
963 },
964 {
965 0, 1, 2, 3, 4, 5, 6, 7
966 },
967 {
968 1, 2, 3, 4, 5, 6, 7, 8
969 },
970 {
971 2, 3, 4, 5, 6, 7, 8, 8
972 },
973 {
974 3, 4, 5, 6, 7, 8, 8, 8
975 },
976 {
977 4, 5, 6, 7, 8, 8, 8, 8
978 },
979 {
980 5, 6, 7, 8, 8, 8, 8, 8
981 },
982 {
983 6, 7, 8, 8, 8, 8, 8, 8
984 },
985 {
986 7, 8, 8, 8, 8, 8, 8, 8
987 },
988 {
989 8, 8, 8, 8, 8, 8, 8, 8
990 }
991 },
992 {
993 {
994 0, 0, 0, 0, 0, 0, 0, 0
995 },
996 {
997 0, 0, 0, 0, 0, 0, 0, 15
998 },
999 {
1000 0, 0, 0, 0, 0, 0, 15, 14
1001 },
1002 {
1003 0, 0, 0, 0, 0, 15, 14, 13
1004 },
1005 {
1006 0, 0, 0, 0, 15, 14, 13, 12
1007 },
1008 {
1009 0, 0, 0, 15, 14, 13, 12, 11
1010 },
1011 {
1012 0, 0, 15, 14, 13, 12, 11, 10
1013 },
1014 {
1015 0, 15, 14, 13, 12, 11, 10, 9
1016 },
1017 {
1018 15, 14, 13, 12, 11, 10, 9, 8
1019 },
1020 {
1021 14, 13, 12, 11, 10, 9, 8, 8
1022 },
1023 {
1024 13, 12, 11, 10, 9, 8, 8, 8
1025 },
1026 {
1027 12, 11, 10, 9, 8, 8, 8, 8
1028 },
1029 {
1030 11, 10, 9, 8, 8, 8, 8, 8
1031 },
1032 {
1033 10, 9, 8, 8, 8, 8, 8, 8
1034 },
1035 {
1036 9, 8, 8, 8, 8, 8, 8, 8
1037 },
1038 {
1039 8, 8, 8, 8, 8, 8, 8, 8
1040 }
1041 }
1042 };
1043 */
1044
1045
1046
1047 /*
1048 for (int32_t blockrow=0; blockrow<30; ++i)
1049 {
1050 for (int32_t linerow=0; linerow<8; ++i)
1051 {
1052 qword *triangleline=(qword*)(tmp_scr->line[(blockrow*8+linerow)]);
1053 for (int32_t blockcolumn=0; blockcolumn<40; ++i)
1054 {
1055 triangleline=triangles[0][screen_triangles[blockrow][blockcolumn]][linerow];
1056 ++triangleline;
1057 }
1058 }
1059 }
1060 */
1061
1062 // the ULL suffixes are to prevent this warning:
1063 // warning: integer constant is too large for "int32_t" type
1064
1065 qword triangles[4][16][8]= //[direction][value][line]
1066 {
1067 {
1068 {
1069 0x0000000000000000ULL,
1070 0x0000000000000000ULL,
1071 0x0000000000000000ULL,
1072 0x0000000000000000ULL,
1073 0x0000000000000000ULL,
1074 0x0000000000000000ULL,
1075 0x0000000000000000ULL,
1076 0x0000000000000000ULL
1077 },
1078 {
1079 0xFD00000000000000ULL,
1080 0x0000000000000000ULL,
1081 0x0000000000000000ULL,
1082 0x0000000000000000ULL,
1083 0x0000000000000000ULL,
1084 0x0000000000000000ULL,
1085 0x0000000000000000ULL,
1086 0x0000000000000000ULL
1087 },
1088 {
1089 0xFDFD000000000000ULL,
1090 0xFD00000000000000ULL,
1091 0x0000000000000000ULL,
1092 0x0000000000000000ULL,
1093 0x0000000000000000ULL,
1094 0x0000000000000000ULL,
1095 0x0000000000000000ULL,
1096 0x0000000000000000ULL
1097 },
1098 {
1099 0xFDFDFD0000000000ULL,
1100 0xFDFD000000000000ULL,
1101 0xFD00000000000000ULL,
1102 0x0000000000000000ULL,
1103 0x0000000000000000ULL,
1104 0x0000000000000000ULL,
1105 0x0000000000000000ULL,
1106 0x0000000000000000ULL
1107 },
1108 {
1109 0xFDFDFDFD00000000ULL,
1110 0xFDFDFD0000000000ULL,
1111 0xFDFD000000000000ULL,
1112 0xFD00000000000000ULL,
1113 0x0000000000000000ULL,
1114 0x0000000000000000ULL,
1115 0x0000000000000000ULL,
1116 0x0000000000000000ULL
1117 },
1118 {
1119 0xFDFDFDFDFD000000ULL,
1120 0xFDFDFDFD00000000ULL,
1121 0xFDFDFD0000000000ULL,
1122 0xFDFD000000000000ULL,
1123 0xFD00000000000000ULL,
1124 0x0000000000000000ULL,
1125 0x0000000000000000ULL,
1126 0x0000000000000000ULL
1127 },
1128 {
1129 0xFDFDFDFDFDFD0000ULL,
1130 0xFDFDFDFDFD000000ULL,
1131 0xFDFDFDFD00000000ULL,
1132 0xFDFDFD0000000000ULL,
1133 0xFDFD000000000000ULL,
1134 0xFD00000000000000ULL,
1135 0x0000000000000000ULL,
1136 0x0000000000000000ULL
1137 },
1138 {
1139 0xFDFDFDFDFDFDFD00ULL,
1140 0xFDFDFDFDFDFD0000ULL,
1141 0xFDFDFDFDFD000000ULL,
1142 0xFDFDFDFD00000000ULL,
1143 0xFDFDFD0000000000ULL,
1144 0xFDFD000000000000ULL,
1145 0xFD00000000000000ULL,
1146 0x0000000000000000ULL
1147 },
1148 {
1149 0xFDFDFDFDFDFDFDFDULL,
1150 0xFDFDFDFDFDFDFD00ULL,
1151 0xFDFDFDFDFDFD0000ULL,
1152 0xFDFDFDFDFD000000ULL,
1153 0xFDFDFDFD00000000ULL,
1154 0xFDFDFD0000000000ULL,
1155 0xFDFD000000000000ULL,
1156 0xFD00000000000000ULL
1157 },
1158 {
1159 0xFDFDFDFDFDFDFDFDULL,
1160 0xFDFDFDFDFDFDFDFDULL,
1161 0xFDFDFDFDFDFDFD00ULL,
1162 0xFDFDFDFDFDFD0000ULL,
1163 0xFDFDFDFDFD000000ULL,
1164 0xFDFDFDFD00000000ULL,
1165 0xFDFDFD0000000000ULL,
1166 0xFDFD000000000000ULL
1167 },
1168 {
1169 0xFDFDFDFDFDFDFDFDULL,
1170 0xFDFDFDFDFDFDFDFDULL,
1171 0xFDFDFDFDFDFDFDFDULL,
1172 0xFDFDFDFDFDFDFD00ULL,
1173 0xFDFDFDFDFDFD0000ULL,
1174 0xFDFDFDFDFD000000ULL,
1175 0xFDFDFDFD00000000ULL,
1176 0xFDFDFD0000000000ULL
1177 },
1178 {
1179 0xFDFDFDFDFDFDFDFDULL,
1180 0xFDFDFDFDFDFDFDFDULL,
1181 0xFDFDFDFDFDFDFDFDULL,
1182 0xFDFDFDFDFDFDFDFDULL,
1183 0xFDFDFDFDFDFDFD00ULL,
1184 0xFDFDFDFDFDFD0000ULL,
1185 0xFDFDFDFDFD000000ULL,
1186 0xFDFDFDFD00000000ULL
1187 },
1188 {
1189 0xFDFDFDFDFDFDFDFDULL,
1190 0xFDFDFDFDFDFDFDFDULL,
1191 0xFDFDFDFDFDFDFDFDULL,
1192 0xFDFDFDFDFDFDFDFDULL,
1193 0xFDFDFDFDFDFDFDFDULL,
1194 0xFDFDFDFDFDFDFD00ULL,
1195 0xFDFDFDFDFDFD0000ULL,
1196 0xFDFDFDFDFD000000ULL
1197 },
1198 {
1199 0xFDFDFDFDFDFDFDFDULL,
1200 0xFDFDFDFDFDFDFDFDULL,
1201 0xFDFDFDFDFDFDFDFDULL,
1202 0xFDFDFDFDFDFDFDFDULL,
1203 0xFDFDFDFDFDFDFDFDULL,
1204 0xFDFDFDFDFDFDFDFDULL,
1205 0xFDFDFDFDFDFDFD00ULL,
1206 0xFDFDFDFDFDFD0000ULL
1207 },
1208 {
1209 0xFDFDFDFDFDFDFDFDULL,
1210 0xFDFDFDFDFDFDFDFDULL,
1211 0xFDFDFDFDFDFDFDFDULL,
1212 0xFDFDFDFDFDFDFDFDULL,
1213 0xFDFDFDFDFDFDFDFDULL,
1214 0xFDFDFDFDFDFDFDFDULL,
1215 0xFDFDFDFDFDFDFDFDULL,
1216 0xFDFDFDFDFDFDFD00ULL
1217 },
1218 {
1219 0xFDFDFDFDFDFDFDFDULL,
1220 0xFDFDFDFDFDFDFDFDULL,
1221 0xFDFDFDFDFDFDFDFDULL,
1222 0xFDFDFDFDFDFDFDFDULL,
1223 0xFDFDFDFDFDFDFDFDULL,
1224 0xFDFDFDFDFDFDFDFDULL,
1225 0xFDFDFDFDFDFDFDFDULL,
1226 0xFDFDFDFDFDFDFDFDULL
1227 }
1228 },
1229 {
1230 {
1231 0x0000000000000000ULL,
1232 0x0000000000000000ULL,
1233 0x0000000000000000ULL,
1234 0x0000000000000000ULL,
1235 0x0000000000000000ULL,
1236 0x0000000000000000ULL,
1237 0x0000000000000000ULL,
1238 0x0000000000000000ULL
1239 },
1240 {
1241 0x00000000000000FDULL,
1242 0x0000000000000000ULL,
1243 0x0000000000000000ULL,
1244 0x0000000000000000ULL,
1245 0x0000000000000000ULL,
1246 0x0000000000000000ULL,
1247 0x0000000000000000ULL,
1248 0x0000000000000000ULL
1249 },
1250 {
1251 0x000000000000FDFDULL,
1252 0x00000000000000FDULL,
1253 0x0000000000000000ULL,
1254 0x0000000000000000ULL,
1255 0x0000000000000000ULL,
1256 0x0000000000000000ULL,
1257 0x0000000000000000ULL,
1258 0x0000000000000000ULL
1259 },
1260 {
1261 0x0000000000FDFDFDULL,
1262 0x000000000000FDFDULL,
1263 0x00000000000000FDULL,
1264 0x0000000000000000ULL,
1265 0x0000000000000000ULL,
1266 0x0000000000000000ULL,
1267 0x0000000000000000ULL,
1268 0x0000000000000000ULL
1269 },
1270 {
1271 0x00000000FDFDFDFDULL,
1272 0x0000000000FDFDFDULL,
1273 0x000000000000FDFDULL,
1274 0x00000000000000FDULL,
1275 0x0000000000000000ULL,
1276 0x0000000000000000ULL,
1277 0x0000000000000000ULL,
1278 0x0000000000000000ULL
1279 },
1280 {
1281 0x000000FDFDFDFDFDULL,
1282 0x00000000FDFDFDFDULL,
1283 0x0000000000FDFDFDULL,
1284 0x000000000000FDFDULL,
1285 0x00000000000000FDULL,
1286 0x0000000000000000ULL,
1287 0x0000000000000000ULL,
1288 0x0000000000000000ULL
1289 },
1290 {
1291 0x0000FDFDFDFDFDFDULL,
1292 0x000000FDFDFDFDFDULL,
1293 0x00000000FDFDFDFDULL,
1294 0x0000000000FDFDFDULL,
1295 0x000000000000FDFDULL,
1296 0x00000000000000FDULL,
1297 0x0000000000000000ULL,
1298 0x0000000000000000ULL
1299 },
1300 {
1301 0x00FDFDFDFDFDFDFDULL,
1302 0x0000FDFDFDFDFDFDULL,
1303 0x000000FDFDFDFDFDULL,
1304 0x00000000FDFDFDFDULL,
1305 0x0000000000FDFDFDULL,
1306 0x000000000000FDFDULL,
1307 0x00000000000000FDULL,
1308 0x0000000000000000ULL
1309 },
1310 {
1311 0xFDFDFDFDFDFDFDFDULL,
1312 0x00FDFDFDFDFDFDFDULL,
1313 0x0000FDFDFDFDFDFDULL,
1314 0x000000FDFDFDFDFDULL,
1315 0x00000000FDFDFDFDULL,
1316 0x0000000000FDFDFDULL,
1317 0x000000000000FDFDULL,
1318 0x00000000000000FDULL
1319 },
1320 {
1321 0xFDFDFDFDFDFDFDFDULL,
1322 0xFDFDFDFDFDFDFDFDULL,
1323 0x00FDFDFDFDFDFDFDULL,
1324 0x0000FDFDFDFDFDFDULL,
1325 0x000000FDFDFDFDFDULL,
1326 0x00000000FDFDFDFDULL,
1327 0x0000000000FDFDFDULL,
1328 0x000000000000FDFDULL
1329 },
1330 {
1331 0xFDFDFDFDFDFDFDFDULL,
1332 0xFDFDFDFDFDFDFDFDULL,
1333 0xFDFDFDFDFDFDFDFDULL,
1334 0x00FDFDFDFDFDFDFDULL,
1335 0x0000FDFDFDFDFDFDULL,
1336 0x000000FDFDFDFDFDULL,
1337 0x00000000FDFDFDFDULL,
1338 0x0000000000FDFDFDULL
1339 },
1340 {
1341 0xFDFDFDFDFDFDFDFDULL,
1342 0xFDFDFDFDFDFDFDFDULL,
1343 0xFDFDFDFDFDFDFDFDULL,
1344 0xFDFDFDFDFDFDFDFDULL,
1345 0x00FDFDFDFDFDFDFDULL,
1346 0x0000FDFDFDFDFDFDULL,
1347 0x000000FDFDFDFDFDULL,
1348 0x00000000FDFDFDFDULL
1349 },
1350 {
1351 0xFDFDFDFDFDFDFDFDULL,
1352 0xFDFDFDFDFDFDFDFDULL,
1353 0xFDFDFDFDFDFDFDFDULL,
1354 0xFDFDFDFDFDFDFDFDULL,
1355 0xFDFDFDFDFDFDFDFDULL,
1356 0x00FDFDFDFDFDFDFDULL,
1357 0x0000FDFDFDFDFDFDULL,
1358 0x000000FDFDFDFDFDULL
1359 },
1360 {
1361 0xFDFDFDFDFDFDFDFDULL,
1362 0xFDFDFDFDFDFDFDFDULL,
1363 0xFDFDFDFDFDFDFDFDULL,
1364 0xFDFDFDFDFDFDFDFDULL,
1365 0xFDFDFDFDFDFDFDFDULL,
1366 0xFDFDFDFDFDFDFDFDULL,
1367 0x00FDFDFDFDFDFDFDULL,
1368 0x0000FDFDFDFDFDFDULL
1369 },
1370 {
1371 0xFDFDFDFDFDFDFDFDULL,
1372 0xFDFDFDFDFDFDFDFDULL,
1373 0xFDFDFDFDFDFDFDFDULL,
1374 0xFDFDFDFDFDFDFDFDULL,
1375 0xFDFDFDFDFDFDFDFDULL,
1376 0xFDFDFDFDFDFDFDFDULL,
1377 0xFDFDFDFDFDFDFDFDULL,
1378 0x00FDFDFDFDFDFDFDULL
1379 },
1380 {
1381 0xFDFDFDFDFDFDFDFDULL,
1382 0xFDFDFDFDFDFDFDFDULL,
1383 0xFDFDFDFDFDFDFDFDULL,
1384 0xFDFDFDFDFDFDFDFDULL,
1385 0xFDFDFDFDFDFDFDFDULL,
1386 0xFDFDFDFDFDFDFDFDULL,
1387 0xFDFDFDFDFDFDFDFDULL,
1388 0xFDFDFDFDFDFDFDFDULL
1389 }
1390 },
1391 {
1392 {
1393 0x0000000000000000ULL,
1394 0x0000000000000000ULL,
1395 0x0000000000000000ULL,
1396 0x0000000000000000ULL,
1397 0x0000000000000000ULL,
1398 0x0000000000000000ULL,
1399 0x0000000000000000ULL,
1400 0x0000000000000000ULL
1401 },
1402 {
1403 0x0000000000000000ULL,
1404 0x0000000000000000ULL,
1405 0x0000000000000000ULL,
1406 0x0000000000000000ULL,
1407 0x0000000000000000ULL,
1408 0x0000000000000000ULL,
1409 0x0000000000000000ULL,
1410 0xFD00000000000000ULL
1411 },
1412 {
1413 0x0000000000000000ULL,
1414 0x0000000000000000ULL,
1415 0x0000000000000000ULL,
1416 0x0000000000000000ULL,
1417 0x0000000000000000ULL,
1418 0x0000000000000000ULL,
1419 0xFD00000000000000ULL,
1420 0xFDFD000000000000ULL
1421 },
1422 {
1423 0x0000000000000000ULL,
1424 0x0000000000000000ULL,
1425 0x0000000000000000ULL,
1426 0x0000000000000000ULL,
1427 0x0000000000000000ULL,
1428 0xFD00000000000000ULL,
1429 0xFDFD000000000000ULL,
1430 0xFDFDFD0000000000ULL
1431 },
1432 {
1433 0x0000000000000000ULL,
1434 0x0000000000000000ULL,
1435 0x0000000000000000ULL,
1436 0x0000000000000000ULL,
1437 0xFD00000000000000ULL,
1438 0xFDFD000000000000ULL,
1439 0xFDFDFD0000000000ULL,
1440 0xFDFDFDFD00000000ULL
1441 },
1442 {
1443 0x0000000000000000ULL,
1444 0x0000000000000000ULL,
1445 0x0000000000000000ULL,
1446 0xFD00000000000000ULL,
1447 0xFDFD000000000000ULL,
1448 0xFDFDFD0000000000ULL,
1449 0xFDFDFDFD00000000ULL,
1450 0xFDFDFDFDFD000000ULL
1451 },
1452 {
1453 0x0000000000000000ULL,
1454 0x0000000000000000ULL,
1455 0xFD00000000000000ULL,
1456 0xFDFD000000000000ULL,
1457 0xFDFDFD0000000000ULL,
1458 0xFDFDFDFD00000000ULL,
1459 0xFDFDFDFDFD000000ULL,
1460 0xFDFDFDFDFDFD0000ULL
1461 },
1462 {
1463 0x0000000000000000ULL,
1464 0xFD00000000000000ULL,
1465 0xFDFD000000000000ULL,
1466 0xFDFDFD0000000000ULL,
1467 0xFDFDFDFD00000000ULL,
1468 0xFDFDFDFDFD000000ULL,
1469 0xFDFDFDFDFDFD0000ULL,
1470 0xFDFDFDFDFDFDFD00ULL
1471 },
1472 {
1473 0xFD00000000000000ULL,
1474 0xFDFD000000000000ULL,
1475 0xFDFDFD0000000000ULL,
1476 0xFDFDFDFD00000000ULL,
1477 0xFDFDFDFDFD000000ULL,
1478 0xFDFDFDFDFDFD0000ULL,
1479 0xFDFDFDFDFDFDFD00ULL,
1480 0xFDFDFDFDFDFDFDFDULL
1481 },
1482 {
1483 0xFDFD000000000000ULL,
1484 0xFDFDFD0000000000ULL,
1485 0xFDFDFDFD00000000ULL,
1486 0xFDFDFDFDFD000000ULL,
1487 0xFDFDFDFDFDFD0000ULL,
1488 0xFDFDFDFDFDFDFD00ULL,
1489 0xFDFDFDFDFDFDFDFDULL,
1490 0xFDFDFDFDFDFDFDFDULL
1491 },
1492 {
1493 0xFDFDFD0000000000ULL,
1494 0xFDFDFDFD00000000ULL,
1495 0xFDFDFDFDFD000000ULL,
1496 0xFDFDFDFDFDFD0000ULL,
1497 0xFDFDFDFDFDFDFD00ULL,
1498 0xFDFDFDFDFDFDFDFDULL,
1499 0xFDFDFDFDFDFDFDFDULL,
1500 0xFDFDFDFDFDFDFDFDULL
1501 },
1502 {
1503 0xFDFDFDFD00000000ULL,
1504 0xFDFDFDFDFD000000ULL,
1505 0xFDFDFDFDFDFD0000ULL,
1506 0xFDFDFDFDFDFDFD00ULL,
1507 0xFDFDFDFDFDFDFDFDULL,
1508 0xFDFDFDFDFDFDFDFDULL,
1509 0xFDFDFDFDFDFDFDFDULL,
1510 0xFDFDFDFDFDFDFDFDULL
1511 },
1512 {
1513 0xFDFDFDFDFD000000ULL,
1514 0xFDFDFDFDFDFD0000ULL,
1515 0xFDFDFDFDFDFDFD00ULL,
1516 0xFDFDFDFDFDFDFDFDULL,
1517 0xFDFDFDFDFDFDFDFDULL,
1518 0xFDFDFDFDFDFDFDFDULL,
1519 0xFDFDFDFDFDFDFDFDULL,
1520 0xFDFDFDFDFDFDFDFDULL
1521 },
1522 {
1523 0xFDFDFDFDFDFD0000ULL,
1524 0xFDFDFDFDFDFDFD00ULL,
1525 0xFDFDFDFDFDFDFDFDULL,
1526 0xFDFDFDFDFDFDFDFDULL,
1527 0xFDFDFDFDFDFDFDFDULL,
1528 0xFDFDFDFDFDFDFDFDULL,
1529 0xFDFDFDFDFDFDFDFDULL,
1530 0xFDFDFDFDFDFDFDFDULL
1531 },
1532 {
1533 0xFDFDFDFDFDFDFD00ULL,
1534 0xFDFDFDFDFDFDFDFDULL,
1535 0xFDFDFDFDFDFDFDFDULL,
1536 0xFDFDFDFDFDFDFDFDULL,
1537 0xFDFDFDFDFDFDFDFDULL,
1538 0xFDFDFDFDFDFDFDFDULL,
1539 0xFDFDFDFDFDFDFDFDULL,
1540 0xFDFDFDFDFDFDFDFDULL
1541 },
1542 {
1543 0xFDFDFDFDFDFDFDFDULL,
1544 0xFDFDFDFDFDFDFDFDULL,
1545 0xFDFDFDFDFDFDFDFDULL,
1546 0xFDFDFDFDFDFDFDFDULL,
1547 0xFDFDFDFDFDFDFDFDULL,
1548 0xFDFDFDFDFDFDFDFDULL,
1549 0xFDFDFDFDFDFDFDFDULL,
1550 0xFDFDFDFDFDFDFDFDULL
1551 }
1552 },
1553 {
1554 {
1555 0x0000000000000000ULL,
1556 0x0000000000000000ULL,
1557 0x0000000000000000ULL,
1558 0x0000000000000000ULL,
1559 0x0000000000000000ULL,
1560 0x0000000000000000ULL,
1561 0x0000000000000000ULL,
1562 0x0000000000000000ULL
1563 },
1564 {
1565 0x0000000000000000ULL,
1566 0x0000000000000000ULL,
1567 0x0000000000000000ULL,
1568 0x0000000000000000ULL,
1569 0x0000000000000000ULL,
1570 0x0000000000000000ULL,
1571 0x0000000000000000ULL,
1572 0x00000000000000FDULL
1573 },
1574 {
1575 0x0000000000000000ULL,
1576 0x0000000000000000ULL,
1577 0x0000000000000000ULL,
1578 0x0000000000000000ULL,
1579 0x0000000000000000ULL,
1580 0x0000000000000000ULL,
1581 0x00000000000000FDULL,
1582 0x000000000000FDFDULL
1583 },
1584 {
1585 0x0000000000000000ULL,
1586 0x0000000000000000ULL,
1587 0x0000000000000000ULL,
1588 0x0000000000000000ULL,
1589 0x0000000000000000ULL,
1590 0x00000000000000FDULL,
1591 0x000000000000FDFDULL,
1592 0x0000000000FDFDFDULL
1593 },
1594 {
1595 0x0000000000000000ULL,
1596 0x0000000000000000ULL,
1597 0x0000000000000000ULL,
1598 0x0000000000000000ULL,
1599 0x00000000000000FDULL,
1600 0x000000000000FDFDULL,
1601 0x0000000000FDFDFDULL,
1602 0x00000000FDFDFDFDULL
1603 },
1604 {
1605 0x0000000000000000ULL,
1606 0x0000000000000000ULL,
1607 0x0000000000000000ULL,
1608 0x00000000000000FDULL,
1609 0x000000000000FDFDULL,
1610 0x0000000000FDFDFDULL,
1611 0x00000000FDFDFDFDULL,
1612 0x000000FDFDFDFDFDULL
1613 },
1614 {
1615 0x0000000000000000ULL,
1616 0x0000000000000000ULL,
1617 0x00000000000000FDULL,
1618 0x000000000000FDFDULL,
1619 0x0000000000FDFDFDULL,
1620 0x00000000FDFDFDFDULL,
1621 0x000000FDFDFDFDFDULL,
1622 0x0000FDFDFDFDFDFDULL
1623 },
1624 {
1625 0x0000000000000000ULL,
1626 0x00000000000000FDULL,
1627 0x000000000000FDFDULL,
1628 0x0000000000FDFDFDULL,
1629 0x00000000FDFDFDFDULL,
1630 0x000000FDFDFDFDFDULL,
1631 0x0000FDFDFDFDFDFDULL,
1632 0x00FDFDFDFDFDFDFDULL
1633 },
1634 {
1635 0x00000000000000FDULL,
1636 0x000000000000FDFDULL,
1637 0x0000000000FDFDFDULL,
1638 0x00000000FDFDFDFDULL,
1639 0x000000FDFDFDFDFDULL,
1640 0x0000FDFDFDFDFDFDULL,
1641 0x00FDFDFDFDFDFDFDULL,
1642 0xFDFDFDFDFDFDFDFDULL
1643 },
1644 {
1645 0x000000000000FDFDULL,
1646 0x0000000000FDFDFDULL,
1647 0x00000000FDFDFDFDULL,
1648 0x000000FDFDFDFDFDULL,
1649 0x0000FDFDFDFDFDFDULL,
1650 0x00FDFDFDFDFDFDFDULL,
1651 0xFDFDFDFDFDFDFDFDULL,
1652 0xFDFDFDFDFDFDFDFDULL
1653 },
1654 {
1655 0x0000000000FDFDFDULL,
1656 0x00000000FDFDFDFDULL,
1657 0x000000FDFDFDFDFDULL,
1658 0x0000FDFDFDFDFDFDULL,
1659 0x00FDFDFDFDFDFDFDULL,
1660 0xFDFDFDFDFDFDFDFDULL,
1661 0xFDFDFDFDFDFDFDFDULL,
1662 0xFDFDFDFDFDFDFDFDULL
1663 },
1664 {
1665 0x00000000FDFDFDFDULL,
1666 0x000000FDFDFDFDFDULL,
1667 0x0000FDFDFDFDFDFDULL,
1668 0x00FDFDFDFDFDFDFDULL,
1669 0xFDFDFDFDFDFDFDFDULL,
1670 0xFDFDFDFDFDFDFDFDULL,
1671 0xFDFDFDFDFDFDFDFDULL,
1672 0xFDFDFDFDFDFDFDFDULL
1673 },
1674 {
1675 0x000000FDFDFDFDFDULL,
1676 0x0000FDFDFDFDFDFDULL,
1677 0x00FDFDFDFDFDFDFDULL,
1678 0xFDFDFDFDFDFDFDFDULL,
1679 0xFDFDFDFDFDFDFDFDULL,
1680 0xFDFDFDFDFDFDFDFDULL,
1681 0xFDFDFDFDFDFDFDFDULL,
1682 0xFDFDFDFDFDFDFDFDULL
1683 },
1684 {
1685 0x0000FDFDFDFDFDFDULL,
1686 0x00FDFDFDFDFDFDFDULL,
1687 0xFDFDFDFDFDFDFDFDULL,
1688 0xFDFDFDFDFDFDFDFDULL,
1689 0xFDFDFDFDFDFDFDFDULL,
1690 0xFDFDFDFDFDFDFDFDULL,
1691 0xFDFDFDFDFDFDFDFDULL,
1692 0xFDFDFDFDFDFDFDFDULL
1693 },
1694 {
1695 0x00FDFDFDFDFDFDFDULL,
1696 0xFDFDFDFDFDFDFDFDULL,
1697 0xFDFDFDFDFDFDFDFDULL,
1698 0xFDFDFDFDFDFDFDFDULL,
1699 0xFDFDFDFDFDFDFDFDULL,
1700 0xFDFDFDFDFDFDFDFDULL,
1701 0xFDFDFDFDFDFDFDFDULL,
1702 0xFDFDFDFDFDFDFDFDULL
1703 },
1704 {
1705 0xFDFDFDFDFDFDFDFDULL,
1706 0xFDFDFDFDFDFDFDFDULL,
1707 0xFDFDFDFDFDFDFDFDULL,
1708 0xFDFDFDFDFDFDFDFDULL,
1709 0xFDFDFDFDFDFDFDFDULL,
1710 0xFDFDFDFDFDFDFDFDULL,
1711 0xFDFDFDFDFDFDFDFDULL,
1712 0xFDFDFDFDFDFDFDFDULL
1713 }
1714 }
1715 };
1716
1717 int32_t black_opening_count=0;
1718 int32_t black_opening_x,black_opening_y;
1719 int32_t black_opening_shape;
1720
1721 791 int32_t choose_opening_shape()
1722 {
1723 // First, count how many bits are set
1724 791 int32_t numBits=0;
1725 int32_t bitCounter;
1726
1727
2/2
✓ Branch 0 taken 3955 times.
✓ Branch 1 taken 791 times.
4746 for(int32_t i=0; i<bosMAX; i++)
1728 {
1729
2/2
✓ Branch 0 taken 2948 times.
✓ Branch 1 taken 1007 times.
3955 if(COOLSCROLL&(1<<i))
1730 1007 numBits++;
1731 3955 }
1732
1733 // Shouldn't happen...
1734
1/2
✓ Branch 0 taken 791 times.
✗ Branch 1 not taken.
791 if(numBits==0)
1735 return bosCIRCLE;
1736
1737 // Pick a bit
1738 791 bitCounter=zc_rand()%numBits+1;
1739
1740
2/2
✓ Branch 0 taken 1003 times.
✓ Branch 1 taken 26 times.
1029 for(int32_t i=0; i<bosMAX; i++)
1741 {
1742 // If this bit is set, decrement the bit counter
1743
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 921 times.
1003 if(COOLSCROLL&(1<<i))
1744 921 bitCounter--;
1745
1746 // When the counter hits 0, return a value based on
1747 // which bit it stopped on.
1748 // Reminder: enum {bosCIRCLE=0, bosOVAL, bosTRIANGLE, bosSMAS, bosFADEBLACK, bosMAX};
1749
2/2
✓ Branch 0 taken 765 times.
✓ Branch 1 taken 238 times.
1003 if(bitCounter==0)
1750 765 return i;
1751 238 }
1752
1753 // Shouldn't be necessary, but the compiler might complain, at least
1754 26 return bosCIRCLE;
1755 791 }
1756
1757 216 void close_black_opening(int32_t x, int32_t y, bool wait, int32_t shape)
1758 {
1759
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 216 times.
216 black_opening_shape= (shape>-1 ? shape : choose_opening_shape());
1760
1761 216 int32_t w=256, h=224;
1762 216 int32_t blockrows=28, blockcolumns=32;
1763 216 int32_t xoffset=(x-(w/2))/8, yoffset=(y-(h/2))/8;
1764
1765
2/2
✓ Branch 0 taken 6048 times.
✓ Branch 1 taken 216 times.
6264 for(int32_t blockrow=0; blockrow<blockrows; ++blockrow) //30
1766 {
1767
2/2
✓ Branch 0 taken 193536 times.
✓ Branch 1 taken 6048 times.
199584 for(int32_t blockcolumn=0; blockcolumn<blockcolumns; ++blockcolumn) //40
1768 {
1769
2/2
✓ Branch 0 taken 103944 times.
✓ Branch 1 taken 89592 times.
193536 screen_triangles[blockrow][blockcolumn]=zc_max(abs(int32_t(double(blockcolumns-1)/2-blockcolumn+xoffset)),abs(int32_t(double(blockrows-1)/2-blockrow+yoffset)))|0x0100|((blockrow-yoffset<blockrows/2)?0:0x8000)|((blockcolumn-xoffset<blockcolumns/2)?0x4000:0);
1770 193536 }
1771 6048 }
1772
1773 216 black_opening_count = 66;
1774 216 black_opening_x = x;
1775 216 black_opening_y = y;
1776 216 lensclk = 0;
1777 //black_opening_shape=(black_opening_shape+1)%bosMAX;
1778
1779
1780
1/2
✓ Branch 0 taken 216 times.
✗ Branch 1 not taken.
216 if(black_opening_shape == bosFADEBLACK)
1781 {
1782 refreshTints();
1783 memcpy(tempblackpal, RAMpal, sizeof(RAMpal)); //Store palette in temp palette for fade effect
1784 }
1785
1/2
✓ Branch 0 taken 216 times.
✗ Branch 1 not taken.
216 if(wait)
1786 {
1787 FFCore.warpScriptCheck();
1788 for(int32_t i=0; i<66; i++)
1789 {
1790 draw_screen(tmpscr);
1791 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
1792 advanceframe(true);
1793
1794 if(Quit)
1795 {
1796 break;
1797 }
1798 }
1799 }
1800 216 }
1801
1802 575 void open_black_opening(int32_t x, int32_t y, bool wait, int32_t shape)
1803 {
1804
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 575 times.
575 black_opening_shape= (shape>-1 ? shape : choose_opening_shape());
1805
1806 575 int32_t w=256, h=224;
1807 575 int32_t blockrows=28, blockcolumns=32;
1808 575 int32_t xoffset=(x-(w/2))/8, yoffset=(y-(h/2))/8;
1809
1810
2/2
✓ Branch 0 taken 16100 times.
✓ Branch 1 taken 575 times.
16675 for(int32_t blockrow=0; blockrow<blockrows; ++blockrow) //30
1811 {
1812
2/2
✓ Branch 0 taken 515200 times.
✓ Branch 1 taken 16100 times.
531300 for(int32_t blockcolumn=0; blockcolumn<blockcolumns; ++blockcolumn) //40
1813 {
1814
2/2
✓ Branch 0 taken 241603 times.
✓ Branch 1 taken 273597 times.
515200 screen_triangles[blockrow][blockcolumn]=zc_max(abs(int32_t(double(blockcolumns-1)/2-blockcolumn+xoffset)),abs(int32_t(double(blockrows-1)/2-blockrow+yoffset)))|0x0100|((blockrow-yoffset<blockrows/2)?0:0x8000)|((blockcolumn-xoffset<blockcolumns/2)?0x4000:0);
1815 515200 }
1816 16100 }
1817
1818 575 black_opening_count = -66;
1819 575 black_opening_x = x;
1820 575 black_opening_y = y;
1821 575 lensclk = 0;
1822
1/2
✓ Branch 0 taken 575 times.
✗ Branch 1 not taken.
575 if(black_opening_shape == bosFADEBLACK)
1823 {
1824 refreshTints();
1825 memcpy(tempblackpal, RAMpal, sizeof(RAMpal)); //Store palette in temp palette for fade effect
1826 }
1827
2/2
✓ Branch 0 taken 110 times.
✓ Branch 1 taken 465 times.
575 if(wait)
1828 {
1829 465 FFCore.warpScriptCheck();
1830
2/2
✓ Branch 0 taken 465 times.
✓ Branch 1 taken 30690 times.
31155 for(int32_t i=0; i<66; i++)
1831 {
1832 30690 draw_screen(tmpscr);
1833 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
1834 30690 advanceframe(true);
1835
1836
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30690 times.
30690 if(Quit)
1837 {
1838 break;
1839 }
1840 30690 }
1841 465 }
1842 575 }
1843
1844 52206 void black_opening(BITMAP *dest,int32_t x,int32_t y,int32_t a,int32_t max_a)
1845 {
1846 52206 clear_to_color(tmp_scr,BLACK);
1847 52206 int32_t w=256, h=224;
1848
1849
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 858 times.
✓ Branch 2 taken 660 times.
✓ Branch 3 taken 1650 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 49038 times.
52206 switch(black_opening_shape)
1850 {
1851 case bosOVAL:
1852 {
1853 858 double new_w=(w/2)+abs(w/2-x);
1854 858 double new_h=(h/2)+abs(h/2-y);
1855 858 double b=sqrt(((new_w*new_w)/4)+(new_h*new_h));
1856 858 ellipsefill(tmp_scr,x,y,int32_t(2*a*b/max_a)/8*8,int32_t(a*b/max_a)/8*8,0);
1857 858 break;
1858 }
1859
1860 case bosTRIANGLE:
1861 {
1862 660 double new_w=(w/2)+abs(w/2-x);
1863 660 double new_h=(h/2)+abs(h/2-y);
1864 660 double r=a*(new_w*sqrt((double)3)+new_h)/max_a;
1865 660 double P2= (PI/2);
1866 660 double P23=(2*PI/3);
1867 660 double P43=(4*PI/3);
1868 660 double Pa= (-4*PI*a/(3*max_a));
1869 660 double angle=P2+Pa;
1870 660 double a0=angle;
1871 660 double a2=angle+P23;
1872 660 double a4=angle+P43;
1873 1320 triangle(tmp_scr, x+int32_t(zc::math::Cos(a0)*r), y-int32_t(zc::math::Sin(a0)*r),
1874 660 x+int32_t(zc::math::Cos(a2)*r), y-int32_t(zc::math::Sin(a2)*r),
1875 660 x+int32_t(zc::math::Cos(a4)*r), y-int32_t(zc::math::Sin(a4)*r),
1876 0);
1877 660 break;
1878 }
1879
1880 case bosSMAS:
1881 {
1882
2/2
✓ Branch 0 taken 660 times.
✓ Branch 1 taken 990 times.
1650 int32_t distance=zc_max(abs(w/2-x),abs(h/2-y))/8;
1883
1884
2/2
✓ Branch 0 taken 46200 times.
✓ Branch 1 taken 1650 times.
47850 for(int32_t blockrow=0; blockrow<28; ++blockrow) //30
1885 {
1886
2/2
✓ Branch 0 taken 369600 times.
✓ Branch 1 taken 46200 times.
415800 for(int32_t linerow=0; linerow<8; ++linerow)
1887 {
1888 369600 qword *triangleline=(qword*)(tmp_scr->line[(blockrow*8+linerow)]);
1889
1890
2/2
✓ Branch 0 taken 11827200 times.
✓ Branch 1 taken 369600 times.
12196800 for(int32_t blockcolumn=0; blockcolumn<32; ++blockcolumn) //40
1891 {
1892 35481600 *triangleline=triangles[(screen_triangles[blockrow][blockcolumn]&0xC000)>>14]
1893
6/6
✓ Branch 0 taken 8249728 times.
✓ Branch 1 taken 3577472 times.
✓ Branch 2 taken 7829672 times.
✓ Branch 3 taken 3997528 times.
✓ Branch 4 taken 4252200 times.
✓ Branch 5 taken 3577472 times.
11827200 [zc_min(zc_max((((31+distance)*(max_a-a)/max_a)+((screen_triangles[blockrow][blockcolumn]&0x0FFF)-0x0100)-(15+distance)),0),15)]
1894 11827200 [linerow];
1895 11827200 ++triangleline;
1896
1897
2/2
✓ Branch 0 taken 10348800 times.
✓ Branch 1 taken 1478400 times.
11827200 if(linerow==0)
1898 {
1899 1478400 }
1900 11827200 }
1901 369600 }
1902 46200 }
1903
1904 1650 break;
1905 }
1906
1907 case bosFADEBLACK:
1908 {
1909 if(black_opening_count<0)
1910 {
1911 black_fade(zc_min(-black_opening_count,63));
1912 }
1913 else if(black_opening_count>0)
1914 {
1915 black_fade(63-zc_max(black_opening_count-3,0));
1916 }
1917 else black_fade(0);
1918 return; //no blitting from tmp_scr!
1919 }
1920
1921 49038 case bosCIRCLE:
1922 default:
1923 {
1924 49038 double new_w=(w/2)+abs(w/2-x);
1925 49038 double new_h=(h/2)+abs(h/2-y);
1926 49038 int32_t r=int32_t(sqrt((new_w*new_w)+(new_h*new_h))*a/max_a);
1927 //circlefill(tmp_scr,x,y,a<<3,0);
1928 49038 circlefill(tmp_scr,x,y,r,0);
1929 49038 break;
1930 }
1931 }
1932
1933 52206 masked_blit(tmp_scr,dest,0,0,0,0,320,240);
1934 52206 }
1935
1936
1937 void black_fade(int32_t fadeamnt)
1938 {
1939 for(int32_t i=0; i < 0xEF; i++)
1940 {
1941 RAMpal[i].r = vbound(tempblackpal[i].r-fadeamnt,0,63);
1942 RAMpal[i].g = vbound(tempblackpal[i].g-fadeamnt,0,63);
1943 RAMpal[i].b = vbound(tempblackpal[i].b-fadeamnt,0,63);
1944 }
1945
1946 refreshpal = true;
1947 }
1948
1949 //----------------------------------------------------------------
1950
1951 15952490 bool item_disabled(int32_t item) //is this item disabled?
1952 {
1953
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15952490 times.
15952490 return (item>=0 && game->items_off[item] != 0);
1954 }
1955
1956 5426600 bool can_use_item(int32_t item_type, int32_t item) //can Hero use this item?
1957 {
1958
2/2
✓ Branch 0 taken 57842 times.
✓ Branch 1 taken 5368758 times.
5426600 if(current_item(item_type, true) >=item)
1959 {
1960 57842 return true;
1961 }
1962
1963 5368758 return false;
1964 5426600 }
1965
1966 22449319 bool has_item(int32_t item_type, int32_t it) //does Hero possess this item?
1967 {
1968
5/9
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 4086346 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2439977 times.
✓ Branch 6 taken 12012783 times.
✓ Branch 7 taken 3882589 times.
✓ Branch 8 taken 27624 times.
22449319 switch(item_type)
1969 {
1970 case itype_bomb:
1971 case itype_sbomb:
1972 {
1973 int32_t itemid = getItemID(itemsbuf, item_type, it);
1974
1975 if(itemid == -1)
1976 return false;
1977
1978 return (game->get_item(itemid));
1979 }
1980
1981 case itype_clock:
1982 {
1983 4086346 int32_t itemid = getItemID(itemsbuf, item_type, it);
1984
1985
2/4
✓ Branch 0 taken 4086346 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4086346 times.
✗ Branch 3 not taken.
4086346 if(itemid != -1 && (itemsbuf[itemid].flags & ITEM_FLAG1)) //Active clock
1986 return (game->get_item(itemid));
1987 4086346 return Hero.getClock()?1:0;
1988 }
1989
1990 case itype_key:
1991 return (game->get_keys()>0);
1992
1993 case itype_magiccontainer:
1994 return (game->get_maxmagic()>=game->get_mp_per_block());
1995
1996 case itype_triforcepiece: //it: -2=any, -1=current level, other=that level
1997 {
1998
1/3
✓ Branch 0 taken 2439977 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
2439977 switch(it)
1999 {
2000 case -2:
2001 {
2002 for(int32_t i=0; i<MAXLEVELS; i++)
2003 {
2004 if(game->lvlitems[i]&liTRIFORCE)
2005 {
2006 return true;
2007 }
2008 }
2009
2010 return false;
2011 }
2012
2013 case -1:
2014 return (game->lvlitems[dlevel]&liTRIFORCE);
2015
2016 default:
2017
2/4
✓ Branch 0 taken 2439977 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2439977 times.
2439977 if(it>=0&&it<MAXLEVELS)
2018 {
2019 2439977 return (game->lvlitems[it]&liTRIFORCE);
2020 }
2021
2022 break;
2023 }
2024
2025 return 0;
2026 }
2027
2028 case itype_map: //it: -2=any, -1=current level, other=that level
2029 {
2030
1/3
✓ Branch 0 taken 12012783 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
12012783 switch(it)
2031 {
2032 case -2:
2033 {
2034 for(int32_t i=0; i<MAXLEVELS; i++)
2035 {
2036 if(game->lvlitems[i]&liMAP)
2037 {
2038 return true;
2039 }
2040 }
2041
2042 return false;
2043 }
2044
2045 case -1:
2046 return (game->lvlitems[dlevel]&liMAP)!=0;
2047
2048 default:
2049
2/4
✓ Branch 0 taken 12012783 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 12012783 times.
12012783 if(it>=0&&it<MAXLEVELS)
2050 {
2051 12012783 return (game->lvlitems[it]&liMAP)!=0;
2052 }
2053
2054 break;
2055 }
2056
2057 return 0;
2058 }
2059
2060 case itype_compass: //it: -2=any, -1=current level, other=that level
2061 {
2062
1/3
✓ Branch 0 taken 3882589 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
3882589 switch(it)
2063 {
2064 case -2:
2065 {
2066 for(int32_t i=0; i<MAXLEVELS; i++)
2067 {
2068 if(game->lvlitems[i]&liCOMPASS)
2069 {
2070 return true;
2071 }
2072 }
2073
2074 return false;
2075 }
2076
2077 case -1:
2078 return (game->lvlitems[dlevel]&liCOMPASS)!=0;
2079
2080 default:
2081
2/4
✓ Branch 0 taken 3882589 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3882589 times.
✗ Branch 3 not taken.
3882589 if(it>=0&&it<MAXLEVELS)
2082 {
2083 3882589 return (game->lvlitems[it]&liCOMPASS)!=0;
2084 }
2085
2086 break;
2087 }
2088 return 0;
2089 }
2090
2091 case itype_bosskey: //it: -2=any, -1=current level, other=that level
2092 {
2093
1/3
✓ Branch 0 taken 27624 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
27624 switch(it)
2094 {
2095 case -2:
2096 {
2097 for(int32_t i=0; i<MAXLEVELS; i++)
2098 {
2099 if(game->lvlitems[i]&liBOSSKEY)
2100 {
2101 return true;
2102 }
2103 }
2104
2105 return false;
2106 }
2107
2108 case -1:
2109 return (game->lvlitems[dlevel]&liBOSSKEY)?1:0;
2110
2111 default:
2112
2/4
✓ Branch 0 taken 27624 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 27624 times.
27624 if(it>=0&&it<MAXLEVELS)
2113 {
2114 27624 return (game->lvlitems[it]&liBOSSKEY)?1:0;
2115 }
2116 break;
2117 }
2118 return 0;
2119 }
2120
2121 default:
2122 //it=(1<<(it-1));
2123 /*if (item_type>=itype_max)
2124 {
2125 system_pal();
2126 jwin_alert("Error","has_item exception",NULL,NULL,"O&K",NULL,'k',0,lfont);
2127 game_pal();
2128
2129 return false;
2130 }*/
2131 int32_t itemid = getItemID(itemsbuf, item_type, it);
2132
2133 if(itemid == -1)
2134 return false;
2135
2136 return game->get_item(itemid);
2137 }
2138 22449319 }
2139
2140
2141 69864896 int32_t current_item(int32_t item_type, bool checkenabled) //item currently being used
2142 {
2143
9/9
✓ Branch 0 taken 4086346 times.
✓ Branch 1 taken 37174128 times.
✓ Branch 2 taken 4086346 times.
✓ Branch 3 taken 4086346 times.
✓ Branch 4 taken 4086346 times.
✓ Branch 5 taken 4086346 times.
✓ Branch 6 taken 4086346 times.
✓ Branch 7 taken 4086346 times.
✓ Branch 8 taken 4086346 times.
69864896 switch(item_type)
2144 {
2145 case itype_clock:
2146 {
2147 4086346 int32_t maxid = getHighestLevelOfFamily(game, itemsbuf, item_type, checkenabled);
2148
2149
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4086346 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4086346 if(maxid != -1 && (itemsbuf[maxid].flags & ITEM_FLAG1)) //Active clock
2150 return itemsbuf[maxid].fam_type;
2151
2152 4086346 return has_item(itype_clock,1) ? 1 : 0;
2153 }
2154
2155 case itype_key:
2156 4086346 return game->get_keys();
2157
2158 case itype_lkey:
2159 4086346 return game->lvlkeys[get_dlevel()];
2160
2161 case itype_magiccontainer:
2162 4086346 return game->get_maxmagic()/game->get_mp_per_block();
2163
2164 case itype_triforcepiece:
2165 {
2166 4086346 int32_t count=0;
2167
2168
2/2
✓ Branch 0 taken 2092209152 times.
✓ Branch 1 taken 4086346 times.
2096295498 for(int32_t i=0; i<MAXLEVELS; i++)
2169 {
2170 2092209152 count+=(game->lvlitems[i]&liTRIFORCE)?1:0;
2171 2092209152 }
2172
2173 4086346 return count;
2174 }
2175
2176 case itype_map:
2177 {
2178 4086346 int32_t count=0;
2179
2180
2/2
✓ Branch 0 taken 2092209152 times.
✓ Branch 1 taken 4086346 times.
2096295498 for(int32_t i=0; i<MAXLEVELS; i++)
2181 {
2182 2092209152 count+=(game->lvlitems[i]&liMAP)?1:0;
2183 2092209152 }
2184
2185 4086346 return count;
2186 }
2187
2188 case itype_compass:
2189 {
2190 4086346 int32_t count=0;
2191
2192
2/2
✓ Branch 0 taken 2092209152 times.
✓ Branch 1 taken 4086346 times.
2096295498 for(int32_t i=0; i<MAXLEVELS; i++)
2193 {
2194 2092209152 count+=(game->lvlitems[i]&liCOMPASS)?1:0;
2195 2092209152 }
2196
2197 4086346 return count;
2198 }
2199
2200 case itype_bosskey:
2201 {
2202 4086346 int32_t count=0;
2203
2204
2/2
✓ Branch 0 taken 2092209152 times.
✓ Branch 1 taken 4086346 times.
2096295498 for(int32_t i=0; i<MAXLEVELS; i++)
2205 {
2206 2092209152 count+=(game->lvlitems[i]&liBOSSKEY)?1:0;
2207 2092209152 }
2208
2209 4086346 return count;
2210 }
2211
2212 default:
2213 37174128 int32_t maxid = getHighestLevelOfFamily(game, itemsbuf, item_type, checkenabled);
2214
2215
2/2
✓ Branch 0 taken 6971048 times.
✓ Branch 1 taken 30203080 times.
37174128 if(maxid == -1)
2216 30203080 return 0;
2217
2218 6971048 return itemsbuf[maxid].fam_type;
2219 }
2220 69864896 }
2221
2222 64438296 int32_t current_item(int32_t item_type) //item currently being used
2223 {
2224 64438296 return current_item(item_type, true);
2225 }
2226
2227 29 std::map<int32_t, int32_t> itemcache;
2228
2229 // Not actually used by anything at the moment...
2230 void removeFromItemCache(int32_t itemid)
2231 {
2232 itemcache.erase(itemid);
2233 }
2234
2235 19096 void flushItemCache()
2236 {
2237 19096 itemcache.clear();
2238
2239 //also fix the active subscreen if items were deleted -DD
2240
1/2
✓ Branch 0 taken 19096 times.
✗ Branch 1 not taken.
19096 if(game != NULL)
2241 {
2242 19096 verifyBothWeapons();
2243 19096 load_Sitems(&QMisc);
2244 19096 }
2245 19096 }
2246
2247 // This is used often, so it should be as direct as possible.
2248 2281812769 int32_t _c_item_id_internal(int32_t itemtype, bool checkmagic, bool jinx_check)
2249 {
2250
2/2
✓ Branch 0 taken 2233008412 times.
✓ Branch 1 taken 48804357 times.
2281812769 if(jinx_check)
2251 {
2252
4/4
✓ Branch 0 taken 31164925 times.
✓ Branch 1 taken 17639432 times.
✓ Branch 2 taken 27758483 times.
✓ Branch 3 taken 3406442 times.
48804357 if(!(HeroSwordClk() || HeroItemClk()))
2253 27758483 jinx_check = false; //not jinxed
2254 48804357 }
2255
4/4
✓ Branch 0 taken 2262409229 times.
✓ Branch 1 taken 19403540 times.
✓ Branch 2 taken 20897290 times.
✓ Branch 3 taken 2241511939 times.
2281812769 if(itemtype!=itype_ring && !jinx_check) // Rings must always be checked, as must jinx checks...
2256 {
2257 2241511939 std::map<int32_t,int32_t>::iterator res = itemcache.find(itemtype);
2258
2259
2/2
✓ Branch 0 taken 2231763427 times.
✓ Branch 1 taken 9748512 times.
2241511939 if(res != itemcache.end())
2260 2231763427 return res->second;
2261 9748512 }
2262
2263 50049342 int32_t result = -1;
2264 50049342 int32_t highestlevel = -1;
2265
2266
2/2
✓ Branch 0 taken 12812631552 times.
✓ Branch 1 taken 50049342 times.
12862680894 for(int32_t i=0; i<MAXITEMS; i++)
2267 {
2268
5/6
✓ Branch 0 taken 1030627526 times.
✓ Branch 1 taken 11782004026 times.
✓ Branch 2 taken 15409861 times.
✓ Branch 3 taken 1015217665 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 15409861 times.
12812631552 if(game->get_item(i) && itemsbuf[i].family==itemtype && !item_disabled(i))
2269 {
2270
4/4
✓ Branch 0 taken 4655389 times.
✓ Branch 1 taken 10754472 times.
✓ Branch 2 taken 1195206 times.
✓ Branch 3 taken 14214655 times.
15409861 if((checkmagic || itemtype == itype_ring) && itemtype != itype_magicring)
2271 {
2272 //printf("Checkmagic for %d: %d (%d %d)\n",i,checkmagiccost(i),itemsbuf[i].magic*game->get_magicdrainrate(),game->get_magic());
2273
2/2
✓ Branch 0 taken 14214535 times.
✓ Branch 1 taken 120 times.
14214655 if(!checkmagiccost(i))
2274 {
2275
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 108 times.
120 if ( !get_bit(quest_rules,qr_NEVERDISABLEAMMOONSUBSCREEN) ) continue; //don't make items with a magic cost vanish!! -Z
2276 12 }
2277 14214547 }
2278
6/6
✓ Branch 0 taken 13234243 times.
✓ Branch 1 taken 2175510 times.
✓ Branch 2 taken 229100 times.
✓ Branch 3 taken 1946410 times.
✓ Branch 4 taken 1458492 times.
✓ Branch 5 taken 717018 times.
15409753 if(jinx_check && (usesSwordJinx(i) ? HeroSwordClk() : HeroItemClk()))
2279 {
2280
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 717018 times.
717018 if(!(itemsbuf[i].flags & ITEM_JINX_IMMUNE))
2281 717018 continue;
2282 }
2283
2284
2/2
✓ Branch 0 taken 223586 times.
✓ Branch 1 taken 14469149 times.
14692735 if(itemsbuf[i].fam_type >= highestlevel)
2285 {
2286 14469149 highestlevel = itemsbuf[i].fam_type;
2287 14469149 result=i;
2288 14469149 }
2289 14692735 }
2290 12811914426 }
2291
2292
2/2
✓ Branch 0 taken 21045874 times.
✓ Branch 1 taken 29003468 times.
50049342 if(!jinx_check) //Can't cache jinx_check results
2293 29003468 itemcache[itemtype] = result;
2294 50049342 return result;
2295 2281812769 }
2296
2297 // 'jinx_check' indicates that the highest level item *immune to jinxes* should be returned.
2298 2261047478 int32_t current_item_id(int32_t itemtype, bool checkmagic, bool jinx_check)
2299 {
2300 2261047478 auto ret = _c_item_id_internal(itemtype,checkmagic,jinx_check);
2301
2/2
✓ Branch 0 taken 28039066 times.
✓ Branch 1 taken 2233008412 times.
2261047478 if(!jinx_check) //If not already a jinx-immune-only check...
2302 {
2303 //And the player IS jinxed...
2304
4/4
✓ Branch 0 taken 2215600485 times.
✓ Branch 1 taken 17407927 times.
✓ Branch 2 taken 3357364 times.
✓ Branch 3 taken 2212243121 times.
2233008412 if(HeroSwordClk() || HeroItemClk())
2305 {
2306 //Then do a jinx-immune-only check here
2307 20765291 auto ret2 = _c_item_id_internal(itemtype,checkmagic,true);
2308 //And *IF IT FINDS A VALID ITEM*, return that one instead! -Em
2309 //Should NOT need a compat rule, as this should always return -1 in old quests.
2310
2/2
✓ Branch 0 taken 974915 times.
✓ Branch 1 taken 19790376 times.
20765291 if(ret2 > -1) return ret2;
2311 19790376 }
2312 2232033497 }
2313 2260072563 return ret;
2314 2261047478 }
2315 14776608 int32_t current_item_power(int32_t itemtype)
2316 {
2317 14776608 int32_t result = current_item_id(itemtype,true);
2318
2/2
✓ Branch 0 taken 11445380 times.
✓ Branch 1 taken 3331228 times.
14776608 return (result<0) ? 0 : itemsbuf[result].power;
2319 }
2320
2321 7 int32_t heart_container_id()
2322 {
2323
1/2
✓ Branch 0 taken 203 times.
✗ Branch 1 not taken.
203 for(int32_t i=0; i<MAXITEMS; i++)
2324 {
2325
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 196 times.
203 if(itemsbuf[i].family == itype_heartcontainer)
2326 {
2327 7 return i;
2328 }
2329 196 }
2330 return -1;
2331 7 }
2332
2333 4086346 int32_t item_tile_mod()
2334 {
2335 4086346 int32_t tile=0;
2336
2337
2/2
✓ Branch 0 taken 975760 times.
✓ Branch 1 taken 3110586 times.
4086346 if(game->get_bombs())
2338 {
2339 3110586 int32_t itemid = current_item_id(itype_bomb,false);
2340
3/4
✓ Branch 0 taken 3029527 times.
✓ Branch 1 taken 81059 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3029527 times.
3110586 if(itemid > -1 && checkbunny(itemid))
2341 3029527 tile+=itemsbuf[itemid].ltm;
2342 3110586 }
2343
2344
2/2
✓ Branch 0 taken 3032663 times.
✓ Branch 1 taken 1053683 times.
4086346 if(game->get_sbombs())
2345 {
2346 1053683 int32_t itemid = current_item_id(itype_sbomb,false);
2347
3/4
✓ Branch 0 taken 1052255 times.
✓ Branch 1 taken 1428 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1052255 times.
1053683 if(itemid > -1 && checkbunny(itemid))
2348 1052255 tile+=itemsbuf[itemid].ltm;
2349 1053683 }
2350
2351
2/2
✓ Branch 0 taken 3998396 times.
✓ Branch 1 taken 87950 times.
4086346 if(current_item(itype_clock))
2352 {
2353 87950 int32_t itemid =
2354
1/2
✓ Branch 0 taken 87950 times.
✗ Branch 1 not taken.
87950 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2355 ? iClock
2356 : getHighestLevelEvenUnowned(itemsbuf, itype_clock);
2357
2/4
✓ Branch 0 taken 87950 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 87950 times.
87950 if(itemid > -1 && checkbunny(itemid))
2358 87950 tile+=itemsbuf[itemid].ltm;
2359 87950 }
2360
2361
2/2
✓ Branch 0 taken 3438526 times.
✓ Branch 1 taken 647820 times.
4086346 if(current_item(itype_key))
2362 {
2363 647820 int32_t itemid =
2364
1/2
✓ Branch 0 taken 647820 times.
✗ Branch 1 not taken.
647820 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2365 ? iKey
2366 : getHighestLevelEvenUnowned(itemsbuf, itype_key);
2367
2/4
✓ Branch 0 taken 647820 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 647820 times.
647820 if(itemid > -1 && checkbunny(itemid))
2368 647820 tile+=itemsbuf[itemid].ltm;
2369 647820 }
2370
2371
2/2
✓ Branch 0 taken 3927093 times.
✓ Branch 1 taken 159253 times.
4086346 if(current_item(itype_lkey))
2372 {
2373 159253 int32_t itemid =
2374
2/2
✓ Branch 0 taken 158343 times.
✓ Branch 1 taken 910 times.
159253 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2375 ? iLevelKey
2376 910 : getHighestLevelEvenUnowned(itemsbuf, itype_lkey);
2377
2/4
✓ Branch 0 taken 159253 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 159253 times.
159253 if(itemid > -1 && checkbunny(itemid))
2378 159253 tile+=itemsbuf[itemid].ltm;
2379 159253 }
2380
2381
2/2
✓ Branch 0 taken 886117 times.
✓ Branch 1 taken 3200229 times.
4086346 if(current_item(itype_map))
2382 {
2383 3200229 int32_t itemid =
2384
2/2
✓ Branch 0 taken 3199443 times.
✓ Branch 1 taken 786 times.
3200229 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2385 ? iMap
2386 786 : getHighestLevelEvenUnowned(itemsbuf, itype_map);
2387
2/4
✓ Branch 0 taken 3200229 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3200229 times.
3200229 if(itemid > -1 && checkbunny(itemid))
2388 3200229 tile+=itemsbuf[itemid].ltm;
2389 3200229 }
2390
2391
2/2
✓ Branch 0 taken 807819 times.
✓ Branch 1 taken 3278527 times.
4086346 if(current_item(itype_compass))
2392 {
2393 3278527 int32_t itemid =
2394
2/2
✓ Branch 0 taken 3197468 times.
✓ Branch 1 taken 81059 times.
3278527 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2395 ? iCompass
2396 81059 : getHighestLevelEvenUnowned(itemsbuf, itype_compass);
2397
2/4
✓ Branch 0 taken 3278527 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3278527 times.
3278527 if(itemid > -1 && checkbunny(itemid))
2398 3278527 tile+=itemsbuf[itemid].ltm;
2399 3278527 }
2400
2401
2/2
✓ Branch 0 taken 2275984 times.
✓ Branch 1 taken 1810362 times.
4086346 if(current_item(itype_bosskey))
2402 {
2403 1810362 int32_t itemid =
2404
1/2
✓ Branch 0 taken 1810362 times.
✗ Branch 1 not taken.
1810362 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2405 ? iBossKey
2406 : getHighestLevelEvenUnowned(itemsbuf, itype_bosskey);
2407
2/4
✓ Branch 0 taken 1810362 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1810362 times.
1810362 if(itemid > -1 && checkbunny(itemid))
2408 1810362 tile+=itemsbuf[itemid].ltm;
2409 1810362 }
2410
2411
2/2
✓ Branch 0 taken 2141126 times.
✓ Branch 1 taken 1945220 times.
4086346 if(current_item(itype_magiccontainer))
2412 {
2413 1945220 int32_t itemid =
2414
2/2
✓ Branch 0 taken 1852005 times.
✓ Branch 1 taken 93215 times.
1945220 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2415 ? iMagicC
2416 93215 : getHighestLevelEvenUnowned(itemsbuf, itype_magiccontainer);
2417
3/4
✓ Branch 0 taken 1945220 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1870 times.
✓ Branch 3 taken 1943350 times.
1945220 if(itemid > -1 && checkbunny(itemid))
2418 1943350 tile+=itemsbuf[itemid].ltm;
2419 1945220 }
2420
2421
2/2
✓ Branch 0 taken 1118041 times.
✓ Branch 1 taken 2968305 times.
4086346 if(current_item(itype_triforcepiece))
2422 {
2423 2968305 int32_t itemid =
2424
1/2
✓ Branch 0 taken 2968305 times.
✗ Branch 1 not taken.
2968305 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2425 ? iTriforce
2426 : getHighestLevelEvenUnowned(itemsbuf, itype_triforcepiece);
2427
2/4
✓ Branch 0 taken 2968305 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2968305 times.
2968305 if(itemid > -1 && checkbunny(itemid))
2428 2968305 tile+=itemsbuf[itemid].ltm;
2429 2968305 }
2430
2431
2/2
✓ Branch 0 taken 4086346 times.
✓ Branch 1 taken 2092209152 times.
2096295498 for(int32_t i=0; i<itype_max; i++)
2432 {
2433
2/2
✓ Branch 0 taken 2035907072 times.
✓ Branch 1 taken 56302080 times.
2092209152 if(!get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS))
2434 {
2435
2/2
✓ Branch 0 taken 1099650 times.
✓ Branch 1 taken 55202430 times.
56302080 switch(i)
2436 {
2437 case itype_bomb:
2438 case itype_sbomb:
2439 case itype_clock:
2440 case itype_key:
2441 case itype_lkey:
2442 case itype_map:
2443 case itype_compass:
2444 case itype_bosskey:
2445 case itype_magiccontainer:
2446 case itype_triforcepiece:
2447 1099650 continue; //already handled
2448 }
2449 55202430 }
2450 2091109502 int32_t itemid = current_item_id(i,false);
2451
2/2
✓ Branch 0 taken 2087023156 times.
✓ Branch 1 taken 4086346 times.
2091109502 if(i == itype_shield)
2452 4086346 itemid = getCurrentShield(false);
2453
2454
4/4
✓ Branch 0 taken 59139201 times.
✓ Branch 1 taken 2031970301 times.
✓ Branch 2 taken 100981 times.
✓ Branch 3 taken 59038220 times.
2091109502 if(itemid < 0 || !checkbunny(itemid))
2455 2032071282 continue;
2456
2457 59038220 itemdata const& itm = itemsbuf[itemid];
2458
2459
2/2
✓ Branch 0 taken 55529396 times.
✓ Branch 1 taken 3508824 times.
59038220 switch(itm.family)
2460 {
2461 case itype_shield:
2462
1/2
✓ Branch 0 taken 3508824 times.
✗ Branch 1 not taken.
3508824 if(itm.flags & ITEM_FLAG9) //active shield
2463 {
2464 if(!usingActiveShield(itemid))
2465 {
2466 tile+=itm.misc6; //'Inactive PTM'
2467 continue;
2468 }
2469 }
2470 3508824 break;
2471 }
2472
2473 59038220 tile+=itm.ltm;
2474 59038220 }
2475
2476 4086346 return tile;
2477 }
2478
2479 4086346 int32_t bunny_tile_mod()
2480 {
2481
2/2
✓ Branch 0 taken 1870 times.
✓ Branch 1 taken 4084476 times.
4086346 if(Hero.BunnyClock())
2482 {
2483 1870 return game->get_bunny_ltm();
2484 }
2485 4084476 return 0;
2486 4086346 }
2487
2488 // Hints are drawn on a separate layer to combo reveals.
2489 16332 void draw_lens_under(BITMAP *dest, bool layer)
2490 {
2491 //Lens flag 1: Replacement for qr_LENSHINTS; if set, lens will show hints. Does nothing if flag 2 is set.
2492 //Lens flag 2: Disable "hints", prevent rendering of Secret Combos
2493 //Lens flag 3: Don't show armos/chest/dive items
2494 //Lens flag 4: Show Raft Paths
2495 //Lens flag 5: Show Invisible Enemies
2496
4/4
✓ Branch 0 taken 456 times.
✓ Branch 1 taken 15876 times.
✓ Branch 2 taken 7938 times.
✓ Branch 3 taken 7938 times.
16332 bool hints = (itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2) ? false : (layer && (itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG1));
2497
2498 16332 int32_t strike_hint_table[11]=
2499 {
2500 mfARROW, mfBOMB, mfBRANG, mfWANDMAGIC,
2501 mfSWORD, mfREFMAGIC, mfHOOKSHOT,
2502 mfREFFIREBALL, mfHAMMER, mfSWORDBEAM, mfWAND
2503 };
2504
2505 // int32_t page = tmpscr->cpage;
2506 {
2507 16332 int32_t blink_rate=flash_reduction_enabled()?6:1;
2508 // int32_t temptimer=0;
2509 16332 int32_t tempitem, tempweapon=0;
2510 16332 strike_hint=strike_hint_table[strike_hint_counter];
2511
2512
2/2
✓ Branch 0 taken 15840 times.
✓ Branch 1 taken 492 times.
16332 if(strike_hint_timer>32)
2513 {
2514 492 strike_hint_timer=0;
2515 492 strike_hint_counter=((strike_hint_counter+1)%11);
2516 492 }
2517
2518 16332 ++strike_hint_timer;
2519
2520
2/2
✓ Branch 0 taken 2874432 times.
✓ Branch 1 taken 16332 times.
2890764 for(int32_t i=0; i<176; i++)
2521 {
2522 2874432 int32_t x = (i & 15) << 4;
2523 2874432 int32_t y = (i & 0xF0) + playing_field_offset;
2524 2874432 int32_t tempitemx=-16, tempitemy=-16;
2525 2874432 int32_t tempweaponx=-16, tempweapony=-16;
2526
2527
2/2
✓ Branch 0 taken 5748864 times.
✓ Branch 1 taken 2874432 times.
8623296 for(int32_t iter=0; iter<2; ++iter)
2528 {
2529 5748864 int32_t checkflag=0;
2530
2531
2/2
✓ Branch 0 taken 2874432 times.
✓ Branch 1 taken 2874432 times.
5748864 if(iter==0)
2532 {
2533 2874432 checkflag=combobuf[tmpscr->data[i]].flag;
2534 2874432 }
2535 else
2536 {
2537 2874432 checkflag=tmpscr->sflag[i];
2538 }
2539
2540
2/2
✓ Branch 0 taken 5747766 times.
✓ Branch 1 taken 1098 times.
5748864 if(checkflag==mfSTRIKE)
2541 {
2542
2/2
✓ Branch 0 taken 192 times.
✓ Branch 1 taken 906 times.
1098 if(!hints)
2543 {
2544
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 906 times.
906 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSTRIKE],tmpscr->secretcset[sSTRIKE]);
2545 906 }
2546 else
2547 {
2548 192 checkflag = strike_hint;
2549 }
2550 1098 }
2551
2552
20/36
✓ Branch 0 taken 5706470 times.
✓ Branch 1 taken 3148 times.
✓ Branch 2 taken 3618 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2064 times.
✓ Branch 5 taken 28640 times.
✓ Branch 6 taken 2418 times.
✓ Branch 7 taken 504 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 814 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✓ Branch 14 taken 33 times.
✓ Branch 15 taken 96 times.
✓ Branch 16 taken 24 times.
✓ Branch 17 taken 5 times.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✓ Branch 21 taken 16 times.
✓ Branch 22 taken 16 times.
✓ Branch 23 taken 7 times.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✓ Branch 27 taken 16 times.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
✓ Branch 31 taken 17 times.
✓ Branch 32 taken 35 times.
✓ Branch 33 taken 17 times.
✗ Branch 34 not taken.
✓ Branch 35 taken 906 times.
5748864 switch(checkflag)
2553 {
2554 case 0:
2555 case mfZELDA:
2556 case mfPUSHED:
2557 case mfENEMY0:
2558 case mfENEMY1:
2559 case mfENEMY2:
2560 case mfENEMY3:
2561 case mfENEMY4:
2562 case mfENEMY5:
2563 case mfENEMY6:
2564 case mfENEMY7:
2565 case mfENEMY8:
2566 case mfENEMY9:
2567 case mfSINGLE:
2568 case mfSINGLE16:
2569 case mfNOENEMY:
2570 case mfTRAP_H:
2571 case mfTRAP_V:
2572 case mfTRAP_4:
2573 case mfTRAP_LR:
2574 case mfTRAP_UD:
2575 case mfNOGROUNDENEMY:
2576 case mfNOBLOCKS:
2577 case mfSCRIPT1:
2578 case mfSCRIPT2:
2579 case mfSCRIPT3:
2580 case mfSCRIPT4:
2581 case mfSCRIPT5:
2582 case mfSCRIPT6:
2583 case mfSCRIPT7:
2584 case mfSCRIPT8:
2585 case mfSCRIPT9:
2586 case mfSCRIPT10:
2587 case mfSCRIPT11:
2588 case mfSCRIPT12:
2589 case mfSCRIPT13:
2590 case mfSCRIPT14:
2591 case mfSCRIPT15:
2592 case mfSCRIPT16:
2593 case mfSCRIPT17:
2594 case mfSCRIPT18:
2595 case mfSCRIPT19:
2596 case mfSCRIPT20:
2597 case mfPITHOLE:
2598 case mfPITFALLFLOOR:
2599 case mfLAVA:
2600 case mfICE:
2601 case mfICEDAMAGE:
2602 case mfDAMAGE1:
2603 case mfDAMAGE2:
2604 case mfDAMAGE4:
2605 case mfDAMAGE8:
2606 case mfDAMAGE16:
2607 case mfDAMAGE32:
2608 case mfFREEZEALL:
2609 case mfFREZEALLANSFFCS:
2610 case mfFREEZEFFCSOLY:
2611 case mfSCRITPTW1TRIG:
2612 case mfSCRITPTW2TRIG:
2613 case mfSCRITPTW3TRIG:
2614 case mfSCRITPTW4TRIG:
2615 case mfSCRITPTW5TRIG:
2616 case mfSCRITPTW6TRIG:
2617 case mfSCRITPTW7TRIG:
2618 case mfSCRITPTW8TRIG:
2619 case mfSCRITPTW9TRIG:
2620 case mfSCRITPTW10TRIG:
2621 case mfTROWEL:
2622 case mfTROWELNEXT:
2623 case mfTROWELSPECIALITEM:
2624 case mfSLASHPOT:
2625 case mfLIFTPOT:
2626 case mfLIFTORSLASH:
2627 case mfLIFTROCK:
2628 case mfLIFTROCKHEAVY:
2629 case mfDROPITEM:
2630 case mfSPECIALITEM:
2631 case mfDROPKEY:
2632 case mfDROPLKEY:
2633 case mfDROPCOMPASS:
2634 case mfDROPMAP:
2635 case mfDROPBOSSKEY:
2636 case mfSPAWNNPC:
2637 case mfSWITCHHOOK:
2638 case mfSIDEVIEWLADDER:
2639 case mfSIDEVIEWPLATFORM:
2640 case mfNOENEMYSPAWN:
2641 case mfENEMYALL:
2642 case mfNOMIRROR:
2643 case mfUNSAFEGROUND:
2644 case mf168:
2645 case mf169:
2646 case mf170:
2647 case mf171:
2648 case mf172:
2649 case mf173:
2650 case mf174:
2651 case mf175:
2652 case mf176:
2653 case mf177:
2654 case mf178:
2655 case mf179:
2656 case mf180:
2657 case mf181:
2658 case mf182:
2659 case mf183:
2660 case mf184:
2661 case mf185:
2662 case mf186:
2663 case mf187:
2664 case mf188:
2665 case mf189:
2666 case mf190:
2667 case mf191:
2668 case mf192:
2669 case mf193:
2670 case mf194:
2671 case mf195:
2672 case mf196:
2673 case mf197:
2674 case mf198:
2675 case mf199:
2676 case mf200:
2677 case mf201:
2678 case mf202:
2679 case mf203:
2680 case mf204:
2681 case mf205:
2682 case mf206:
2683 case mf207:
2684 case mf208:
2685 case mf209:
2686 case mf210:
2687 case mf211:
2688 case mf212:
2689 case mf213:
2690 case mf214:
2691 case mf215:
2692 case mf216:
2693 case mf217:
2694 case mf218:
2695 case mf219:
2696 case mf220:
2697 case mf221:
2698 case mf222:
2699 case mf223:
2700 case mf224:
2701 case mf225:
2702 case mf226:
2703 case mf227:
2704 case mf228:
2705 case mf229:
2706 case mf230:
2707 case mf231:
2708 case mf232:
2709 case mf233:
2710 case mf234:
2711 case mf235:
2712 case mf236:
2713 case mf237:
2714 case mf238:
2715 case mf239:
2716 case mf240:
2717 case mf241:
2718 case mf242:
2719 case mf243:
2720 case mf244:
2721 case mf245:
2722 case mf246:
2723 case mf247:
2724 case mf248:
2725 case mf249:
2726 case mf250:
2727 case mf251:
2728 case mf252:
2729 case mf253:
2730 case mf254:
2731 case mfEXTENDED:
2732 5706470 break;
2733
2734 case mfPUSHUD:
2735 case mfPUSHLR:
2736 case mfPUSH4:
2737 case mfPUSHU:
2738 case mfPUSHD:
2739 case mfPUSHL:
2740 case mfPUSHR:
2741 case mfPUSHUDNS:
2742 case mfPUSHLRNS:
2743 case mfPUSH4NS:
2744 case mfPUSHUNS:
2745 case mfPUSHDNS:
2746 case mfPUSHLNS:
2747 case mfPUSHRNS:
2748 case mfPUSHUDINS:
2749 case mfPUSHLRINS:
2750 case mfPUSH4INS:
2751 case mfPUSHUINS:
2752 case mfPUSHDINS:
2753 case mfPUSHLINS:
2754 case mfPUSHRINS:
2755
3/4
✓ Branch 0 taken 1829 times.
✓ Branch 1 taken 1319 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1829 times.
3148 if(!hints && ((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&16))
2756
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1829 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1829 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1829 || ((get_debug() && zc_getkey(KEY_N)) && (frame&16))))
2757 {
2758 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->undercombo,tmpscr->undercset);
2759 }
2760
2761
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3148 times.
3148 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2762
3/6
✓ Branch 0 taken 2438 times.
✓ Branch 1 taken 710 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 710 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
3148 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2763 {
2764
2/2
✓ Branch 0 taken 1406 times.
✓ Branch 1 taken 1032 times.
2438 if(hints)
2765 {
2766
3/3
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 63 times.
✓ Branch 2 taken 897 times.
1032 switch(combobuf[tmpscr->data[i]].type)
2767 {
2768 case cPUSH_HEAVY:
2769 case cPUSH_HW:
2770 72 tempitem=getItemIDPower(itemsbuf,itype_bracelet,1);
2771 72 tempitemx=x, tempitemy=y;
2772
2773
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 72 times.
72 if(tempitem>-1)
2774 72 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2775
2776 72 break;
2777
2778 case cPUSH_HEAVY2:
2779 case cPUSH_HW2:
2780 63 tempitem=getItemIDPower(itemsbuf,itype_bracelet,2);
2781 63 tempitemx=x, tempitemy=y;
2782
2783
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 63 times.
63 if(tempitem>-1)
2784 63 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2785
2786 63 break;
2787 }
2788 1032 }
2789 2438 }
2790
2791 3148 break;
2792
2793 case mfWHISTLE:
2794
1/2
✓ Branch 0 taken 2418 times.
✗ Branch 1 not taken.
2418 if(hints)
2795 {
2796 tempitem=getItemID(itemsbuf,itype_whistle,1);
2797
2798 if(tempitem<0) break;
2799
2800 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2801 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2802 {
2803 tempitemx=x;
2804 tempitemy=y;
2805 }
2806
2807 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2808 }
2809
2810 2418 break;
2811
2812 //Why is this here?
2813 case mfFAIRY:
2814 case mfMAGICFAIRY:
2815 case mfALLFAIRY:
2816 if(hints)
2817 {
2818 tempitem=getItemID(itemsbuf, itype_fairy,1);//iFairyMoving;
2819
2820 if(tempitem < 0) break;
2821
2822 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2823 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2824 {
2825 tempitemx=x;
2826 tempitemy=y;
2827 }
2828
2829 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2830 }
2831
2832 break;
2833
2834 case mfBCANDLE:
2835
2/2
✓ Branch 0 taken 252 times.
✓ Branch 1 taken 252 times.
504 if(!hints)
2836 {
2837
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 252 times.
252 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sBCANDLE],tmpscr->secretcset[sBCANDLE]);
2838 252 }
2839 else
2840 {
2841 252 tempitem=getItemID(itemsbuf,itype_candle,1);
2842
2843
1/2
✓ Branch 0 taken 252 times.
✗ Branch 1 not taken.
252 if(tempitem<0) break;
2844
2845
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 252 times.
252 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2846
3/6
✓ Branch 0 taken 189 times.
✓ Branch 1 taken 63 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 63 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
252 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2847 {
2848 189 tempitemx=x;
2849 189 tempitemy=y;
2850 189 }
2851
2852 252 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2853 }
2854
2855 504 break;
2856
2857 case mfRCANDLE:
2858 if(!hints)
2859 {
2860 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sRCANDLE],tmpscr->secretcset[sRCANDLE]);
2861 }
2862 else
2863 {
2864 tempitem=getItemID(itemsbuf,itype_candle,2);
2865
2866 if(tempitem<0) break;
2867
2868 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2869 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2870 {
2871 tempitemx=x;
2872 tempitemy=y;
2873 }
2874
2875 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2876 }
2877
2878 break;
2879
2880 case mfWANDFIRE:
2881 if(!hints)
2882 {
2883 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWANDFIRE],tmpscr->secretcset[sWANDFIRE]);
2884 }
2885 else
2886 {
2887 tempitem=getItemID(itemsbuf,itype_wand,1);
2888
2889 if(tempitem<0) break;
2890
2891 tempweapon=wFire;
2892
2893 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2894 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2895 {
2896 tempitemx=x;
2897 tempitemy=y;
2898 }
2899 else
2900 {
2901 tempweaponx=x;
2902 tempweapony=y;
2903 }
2904
2905 putweapon(dest,tempweaponx,tempweapony,tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
2906 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2907 }
2908
2909 break;
2910
2911 case mfDINSFIRE:
2912 if(!hints)
2913 {
2914 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sDINSFIRE],tmpscr->secretcset[sDINSFIRE]);
2915 }
2916 else
2917 {
2918 tempitem=getItemID(itemsbuf,itype_dinsfire,1);
2919
2920 if(tempitem<0) break;
2921
2922 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2923 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2924 {
2925 tempitemx=x;
2926 tempitemy=y;
2927 }
2928
2929 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2930 }
2931
2932 break;
2933
2934 case mfARROW:
2935
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 732 times.
814 if(!hints)
2936 {
2937
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 732 times.
732 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sARROW],tmpscr->secretcset[sARROW]);
2938 732 }
2939 else
2940 {
2941 82 tempitem=getItemID(itemsbuf,itype_arrow,1);
2942
2943
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 if(tempitem<0) break;
2944
2945
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 82 times.
82 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2946
3/6
✓ Branch 0 taken 61 times.
✓ Branch 1 taken 21 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 21 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
82 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2947 {
2948 61 tempitemx=x;
2949 61 tempitemy=y;
2950 61 }
2951
2952 82 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2953 }
2954
2955 814 break;
2956
2957 case mfSARROW:
2958 if(!hints)
2959 {
2960 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSARROW],tmpscr->secretcset[sSARROW]);
2961 }
2962 else
2963 {
2964 tempitem=getItemID(itemsbuf,itype_arrow,2);
2965
2966 if(tempitem<0) break;
2967
2968 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2969 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2970 {
2971 tempitemx=x;
2972 tempitemy=y;
2973 }
2974
2975 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2976 }
2977
2978 break;
2979
2980 case mfGARROW:
2981 if(!hints)
2982 {
2983 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sGARROW],tmpscr->secretcset[sGARROW]);
2984 }
2985 else
2986 {
2987 tempitem=getItemID(itemsbuf,itype_arrow,3);
2988
2989 if(tempitem<0) break;
2990
2991 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2992 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2993 {
2994 tempitemx=x;
2995 tempitemy=y;
2996 }
2997
2998 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2999 }
3000
3001 break;
3002
3003 case mfBOMB:
3004
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 16 times.
33 if(!hints)
3005 {
3006
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sBOMB],tmpscr->secretcset[sBOMB]);
3007 16 }
3008 else
3009 {
3010 //tempitem=getItemID(itemsbuf,itype_bomb,1);
3011 17 tempweapon = wLitBomb;
3012
3013 //if (tempitem<0) break;
3014
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3015
3/6
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
17 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3016 {
3017 12 tempweaponx=x;
3018 12 tempweapony=y;
3019 12 }
3020
3021 17 putweapon(dest,tempweaponx,tempweapony+lens_hint_weapon[tempweapon][4],tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3022 }
3023
3024 33 break;
3025
3026 case mfSBOMB:
3027
2/2
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 48 times.
96 if(!hints)
3028 {
3029
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
48 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSBOMB],tmpscr->secretcset[sSBOMB]);
3030 48 }
3031 else
3032 {
3033 //tempitem=getItemID(itemsbuf,itype_sbomb,1);
3034 //if (tempitem<0) break;
3035 48 tempweapon = wLitSBomb;
3036
3037
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
48 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3038
3/6
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 12 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
48 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3039 {
3040 36 tempweaponx=x;
3041 36 tempweapony=y;
3042 36 }
3043
3044 48 putweapon(dest,tempweaponx,tempweapony+lens_hint_weapon[tempweapon][4],tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3045 }
3046
3047 96 break;
3048
3049 case mfARMOS_SECRET:
3050
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 12 times.
24 if(!hints)
3051 {
3052
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSTAIRS],tmpscr->secretcset[sSTAIRS]);
3053 12 }
3054 24 break;
3055
3056 case mfBRANG:
3057
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(!hints)
3058 {
3059 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sBRANG],tmpscr->secretcset[sBRANG]);
3060 }
3061 else
3062 {
3063 5 tempitem=getItemID(itemsbuf,itype_brang,1);
3064
3065
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(tempitem<0) break;
3066
3067
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3068
3/6
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
5 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3069 {
3070 4 tempitemx=x;
3071 4 tempitemy=y;
3072 4 }
3073
3074 5 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3075 }
3076
3077 5 break;
3078
3079 case mfMBRANG:
3080 if(!hints)
3081 {
3082 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sMBRANG],tmpscr->secretcset[sMBRANG]);
3083 }
3084 else
3085 {
3086 tempitem=getItemID(itemsbuf,itype_brang,2);
3087
3088 if(tempitem<0) break;
3089
3090 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3091 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3092 {
3093 tempitemx=x;
3094 tempitemy=y;
3095 }
3096
3097 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3098 }
3099
3100 break;
3101
3102 case mfFBRANG:
3103 if(!hints)
3104 {
3105 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sFBRANG],tmpscr->secretcset[sFBRANG]);
3106 }
3107 else
3108 {
3109 tempitem=getItemID(itemsbuf,itype_brang,3);
3110
3111 if(tempitem<0) break;
3112
3113 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3114 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3115 {
3116 tempitemx=x;
3117 tempitemy=y;
3118 }
3119
3120 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3121 }
3122
3123 break;
3124
3125 case mfWANDMAGIC:
3126 if(!hints)
3127 {
3128 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWANDMAGIC],tmpscr->secretcset[sWANDMAGIC]);
3129 }
3130 else
3131 {
3132 tempitem=getItemID(itemsbuf,itype_wand,1);
3133
3134 if(tempitem<0) break;
3135
3136 tempweapon=itemsbuf[tempitem].wpn3;
3137
3138 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3139 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3140 {
3141 tempitemx=x;
3142 tempitemy=y;
3143 }
3144 else
3145 {
3146 tempweaponx=x;
3147 tempweapony=y;
3148 --lens_hint_weapon[wMagic][4];
3149
3150 if(lens_hint_weapon[wMagic][4]<-8)
3151 {
3152 lens_hint_weapon[wMagic][4]=8;
3153 }
3154 }
3155
3156 putweapon(dest,tempweaponx,tempweapony+lens_hint_weapon[tempweapon][4],tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3157 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3158 }
3159
3160 break;
3161
3162 case mfREFMAGIC:
3163
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!hints)
3164 {
3165 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sREFMAGIC],tmpscr->secretcset[sREFMAGIC]);
3166 }
3167 else
3168 {
3169 16 tempitem=getItemID(itemsbuf,itype_shield,3);
3170
3171
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(tempitem<0) break;
3172
3173 16 tempweapon=ewMagic;
3174
3175
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3176
3/6
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
16 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3177 {
3178 13 tempitemx=x;
3179 13 tempitemy=y;
3180 13 }
3181 else
3182 {
3183 3 tempweaponx=x;
3184 3 tempweapony=y;
3185
3186
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 1 times.
3 if(lens_hint_weapon[ewMagic][2]==up)
3187 {
3188 1 --lens_hint_weapon[ewMagic][4];
3189 1 }
3190 else
3191 {
3192 2 ++lens_hint_weapon[ewMagic][4];
3193 }
3194
3195
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(lens_hint_weapon[ewMagic][4]>8)
3196 {
3197 lens_hint_weapon[ewMagic][2]=up;
3198 }
3199
3200
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 2 times.
3 if(lens_hint_weapon[ewMagic][4]<=0)
3201 {
3202 2 lens_hint_weapon[ewMagic][2]=down;
3203 2 }
3204 }
3205
3206 16 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3207 16 putweapon(dest,tempweaponx,tempweapony+lens_hint_weapon[tempweapon][4],tempweapon, 0, lens_hint_weapon[ewMagic][2], lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3208 }
3209
3210 16 break;
3211
3212 case mfREFFIREBALL:
3213
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!hints)
3214 {
3215 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sREFFIREBALL],tmpscr->secretcset[sREFFIREBALL]);
3216 }
3217 else
3218 {
3219 16 tempitem=getItemID(itemsbuf,itype_shield,3);
3220
3221
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(tempitem<0) break;
3222
3223 16 tempweapon=ewFireball;
3224
3225
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3226
3/6
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
16 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3227 {
3228 12 tempitemx=x;
3229 12 tempitemy=y;
3230 12 tempweaponx=x;
3231 12 tempweapony=y;
3232 12 ++lens_hint_weapon[ewFireball][3];
3233
3234
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 1 times.
12 if(lens_hint_weapon[ewFireball][3]>8)
3235 {
3236 1 lens_hint_weapon[ewFireball][3]=-8;
3237 1 lens_hint_weapon[ewFireball][4]=8;
3238 1 }
3239
3240
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 4 times.
12 if(lens_hint_weapon[ewFireball][3]>0)
3241 {
3242 8 ++lens_hint_weapon[ewFireball][4];
3243 8 }
3244 else
3245 {
3246 4 --lens_hint_weapon[ewFireball][4];
3247 }
3248 12 }
3249
3250 16 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3251 16 putweapon(dest,tempweaponx+lens_hint_weapon[tempweapon][3],tempweapony+lens_hint_weapon[ewFireball][4],tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3252 }
3253
3254 16 break;
3255
3256 case mfSWORD:
3257
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 if(!hints)
3258 {
3259 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSWORD],tmpscr->secretcset[sSWORD]);
3260 }
3261 else
3262 {
3263 7 tempitem=getItemID(itemsbuf,itype_sword,1);
3264
3265
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 if(tempitem<0) break;
3266
3267
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
7 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3268
3/6
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
7 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3269 {
3270 5 tempitemx=x;
3271 5 tempitemy=y;
3272 5 }
3273
3274 7 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3275 }
3276
3277 7 break;
3278
3279 case mfWSWORD:
3280 if(!hints)
3281 {
3282 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWSWORD],tmpscr->secretcset[sWSWORD]);
3283 }
3284 else
3285 {
3286 tempitem=getItemID(itemsbuf,itype_sword,2);
3287
3288 if(tempitem<0) break;
3289
3290 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3291 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3292 {
3293 tempitemx=x;
3294 tempitemy=y;
3295 }
3296
3297 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3298 }
3299
3300 break;
3301
3302 case mfMSWORD:
3303 if(!hints)
3304 {
3305 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sMSWORD],tmpscr->secretcset[sMSWORD]);
3306 }
3307 else
3308 {
3309 tempitem=getItemID(itemsbuf,itype_sword,3);
3310
3311 if(tempitem<0) break;
3312
3313 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3314 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3315 {
3316 tempitemx=x;
3317 tempitemy=y;
3318 }
3319
3320 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3321 }
3322
3323 break;
3324
3325 case mfXSWORD:
3326 if(!hints)
3327 {
3328 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sXSWORD],tmpscr->secretcset[sXSWORD]);
3329 }
3330 else
3331 {
3332 tempitem=getItemID(itemsbuf,itype_sword,4);
3333
3334 if(tempitem<0) break;
3335
3336 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3337 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3338 {
3339 tempitemx=x;
3340 tempitemy=y;
3341 }
3342
3343 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3344 }
3345
3346 break;
3347
3348 case mfSWORDBEAM:
3349
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!hints)
3350 {
3351 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSWORDBEAM],tmpscr->secretcset[sSWORDBEAM]);
3352 }
3353 else
3354 {
3355 16 tempitem=getItemID(itemsbuf,itype_sword,1);
3356
3357
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(tempitem<0) break;
3358
3359
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3360
3/6
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
16 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3361 {
3362 11 tempitemx=x;
3363 11 tempitemy=y;
3364 11 }
3365
3366 16 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 1);
3367 }
3368
3369 16 break;
3370
3371 case mfWSWORDBEAM:
3372 if(!hints)
3373 {
3374 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWSWORDBEAM],tmpscr->secretcset[sWSWORDBEAM]);
3375 }
3376 else
3377 {
3378 tempitem=getItemID(itemsbuf,itype_sword,2);
3379
3380 if(tempitem<0) break;
3381
3382 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3383 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3384 {
3385 tempitemx=x;
3386 tempitemy=y;
3387 }
3388
3389 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 2);
3390 }
3391
3392 break;
3393
3394 case mfMSWORDBEAM:
3395 if(!hints)
3396 {
3397 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sMSWORDBEAM],tmpscr->secretcset[sMSWORDBEAM]);
3398 }
3399 else
3400 {
3401 tempitem=getItemID(itemsbuf,itype_sword,3);
3402
3403 if(tempitem<0) break;
3404
3405 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3406 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3407 {
3408 tempitemx=x;
3409 tempitemy=y;
3410 }
3411
3412 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 3);
3413 }
3414
3415 break;
3416
3417 case mfXSWORDBEAM:
3418 if(!hints)
3419 {
3420 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sXSWORDBEAM],tmpscr->secretcset[sXSWORDBEAM]);
3421 }
3422 else
3423 {
3424 tempitem=getItemID(itemsbuf,itype_sword,4);
3425
3426 if(tempitem<0) break;
3427
3428 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3429 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3430 {
3431 tempitemx=x;
3432 tempitemy=y;
3433 }
3434
3435 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 4);
3436 }
3437
3438 break;
3439
3440 case mfHOOKSHOT:
3441
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!hints)
3442 {
3443 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sHOOKSHOT],tmpscr->secretcset[sHOOKSHOT]);
3444 }
3445 else
3446 {
3447 17 tempitem=getItemID(itemsbuf,itype_hookshot,1);
3448
3449
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(tempitem<0) break;
3450
3451
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3452
3/6
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
17 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3453 {
3454 12 tempitemx=x;
3455 12 tempitemy=y;
3456 12 }
3457
3458 17 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3459 }
3460
3461 17 break;
3462
3463 case mfWAND:
3464
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(!hints)
3465 {
3466 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWAND],tmpscr->secretcset[sWAND]);
3467 }
3468 else
3469 {
3470 35 tempitem=getItemID(itemsbuf,itype_wand,1);
3471
3472
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(tempitem<0) break;
3473
3474
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35 times.
35 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3475
3/6
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
35 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3476 {
3477 28 tempitemx=x;
3478 28 tempitemy=y;
3479 28 }
3480
3481 35 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3482 }
3483
3484 35 break;
3485
3486 case mfHAMMER:
3487
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!hints)
3488 {
3489 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sHAMMER],tmpscr->secretcset[sHAMMER]);
3490 }
3491 else
3492 {
3493 17 tempitem=getItemID(itemsbuf,itype_hammer,1);
3494
3495
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(tempitem<0) break;
3496
3497
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3498
3/6
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
17 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3499 {
3500 13 tempitemx=x;
3501 13 tempitemy=y;
3502 13 }
3503
3504 17 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3505 }
3506
3507 17 break;
3508
3509 case mfARMOS_ITEM:
3510 case mfDIVE_ITEM:
3511
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2064 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2064 times.
2064 if((!getmapflag() || (tmpscr->flags9&fBELOWRETURN)) && !(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG3))
3512 {
3513 2064 putitem2(dest,x,y,tmpscr->catchall, lens_hint_item[tmpscr->catchall][0], lens_hint_item[tmpscr->catchall][1], 0);
3514 2064 }
3515 2064 break;
3516
3517 case 16:
3518 case 17:
3519 case 18:
3520 case 19:
3521 case 20:
3522 case 21:
3523 case 22:
3524 case 23:
3525 case 24:
3526 case 25:
3527 case 26:
3528 case 27:
3529 case 28:
3530 case 29:
3531 case 30:
3532 case 31:
3533
2/2
✓ Branch 0 taken 1008 times.
✓ Branch 1 taken 2610 times.
3618 if(!hints)
3534
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2610 times.
5220 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))
3535 2610 putcombo(dest,x,y,tmpscr->secretcombo[checkflag-16+4],tmpscr->secretcset[checkflag-16+4]);
3536
3537 3618 break;
3538 case mfSECRETSNEXT:
3539 if(!hints)
3540 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))
3541 putcombo(dest,x,y,tmpscr->data[i]+1,tmpscr->cset[i]);
3542
3543 break;
3544
3545 case mfSTRIKE:
3546
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 906 times.
906 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))
3547 {
3548 906 goto special;
3549 }
3550 else
3551 {
3552 break;
3553 }
3554
3555 28640 default: goto special;
3556
3557 special:
3558
8/8
✓ Branch 0 taken 14677 times.
✓ Branch 1 taken 14869 times.
✓ Branch 2 taken 473 times.
✓ Branch 3 taken 14204 times.
✓ Branch 4 taken 441 times.
✓ Branch 5 taken 32 times.
✓ Branch 6 taken 6108 times.
✓ Branch 7 taken 8128 times.
29546 if(layer && ((checkflag!=mfRAFT && checkflag!=mfRAFT_BRANCH&& checkflag!=mfRAFT_BOUNCE) ||(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG4)))
3559 {
3560
4/8
✗ Branch 0 not taken.
✓ Branch 1 taken 6549 times.
✓ Branch 2 taken 4913 times.
✓ Branch 3 taken 1636 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1636 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
6549 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate)) || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3561 {
3562 4913 rectfill(dest,x,y,x+15,y+15,WHITE);
3563 4913 }
3564 6549 }
3565
3566 29546 break;
3567 }
3568 5748864 }
3569 2874432 }
3570
3571
2/2
✓ Branch 0 taken 8166 times.
✓ Branch 1 taken 8166 times.
16332 if(layer)
3572 {
3573
2/2
✓ Branch 0 taken 7978 times.
✓ Branch 1 taken 188 times.
8166 if(tmpscr->door[0]==dWALK)
3574 188 rectfill(dest, 120, 16+playing_field_offset, 135, 31+playing_field_offset, WHITE);
3575
3576
2/2
✓ Branch 0 taken 7969 times.
✓ Branch 1 taken 197 times.
8166 if(tmpscr->door[1]==dWALK)
3577 197 rectfill(dest, 120, 144+playing_field_offset, 135, 159+playing_field_offset, WHITE);
3578
3579
2/2
✓ Branch 0 taken 8014 times.
✓ Branch 1 taken 152 times.
8166 if(tmpscr->door[2]==dWALK)
3580 152 rectfill(dest, 16, 80+playing_field_offset, 31, 95+playing_field_offset, WHITE);
3581
3582
2/2
✓ Branch 0 taken 7940 times.
✓ Branch 1 taken 226 times.
8166 if(tmpscr->door[3]==dWALK)
3583 226 rectfill(dest, 224, 80+playing_field_offset, 239, 95+playing_field_offset, WHITE);
3584
3585
2/2
✓ Branch 0 taken 8123 times.
✓ Branch 1 taken 43 times.
8166 if(tmpscr->door[0]==dBOMB)
3586 {
3587 43 showbombeddoor(dest, 0);
3588 43 }
3589
3590
2/2
✓ Branch 0 taken 8127 times.
✓ Branch 1 taken 39 times.
8166 if(tmpscr->door[1]==dBOMB)
3591 {
3592 39 showbombeddoor(dest, 1);
3593 39 }
3594
3595
1/2
✓ Branch 0 taken 8166 times.
✗ Branch 1 not taken.
8166 if(tmpscr->door[2]==dBOMB)
3596 {
3597 showbombeddoor(dest, 2);
3598 }
3599
3600
2/2
✓ Branch 0 taken 8129 times.
✓ Branch 1 taken 37 times.
8166 if(tmpscr->door[3]==dBOMB)
3601 {
3602 37 showbombeddoor(dest, 3);
3603 37 }
3604 8166 }
3605
3606
2/2
✓ Branch 0 taken 14298 times.
✓ Branch 1 taken 2034 times.
16332 if(tmpscr->stairx + tmpscr->stairy)
3607 {
3608
2/2
✓ Branch 0 taken 911 times.
✓ Branch 1 taken 1123 times.
2034 if(!hints)
3609 {
3610
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1123 times.
1123 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))
3611 1123 putcombo(dest,tmpscr->stairx,tmpscr->stairy+playing_field_offset,tmpscr->secretcombo[sSTAIRS],tmpscr->secretcset[sSTAIRS]);
3612 1123 }
3613 else
3614 {
3615
2/2
✓ Branch 0 taken 863 times.
✓ Branch 1 taken 48 times.
911 if(tmpscr->flags&fWHISTLE)
3616 {
3617 48 tempitem=getItemID(itemsbuf,itype_whistle,1);
3618 48 int32_t tempitemx=-16;
3619 48 int32_t tempitemy=-16;
3620
3621
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
48 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&(blink_rate/4)))
3622
3/6
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 24 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 24 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
48 || ((get_debug() && zc_getkey(KEY_N)) && (frame&(blink_rate/4))))
3623 {
3624 24 tempitemx=tmpscr->stairx;
3625 24 tempitemy=tmpscr->stairy+playing_field_offset;
3626 24 }
3627
3628 48 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3629 48 }
3630 }
3631 2034 }
3632 }
3633 16332 }
3634
3635 BITMAP *lens_scr_d; // The "d" is for "destructible"!
3636
3637 7997 void draw_lens_over()
3638 {
3639 // Oh, what the heck.
3640 static BITMAP *lens_scr = NULL;
3641 static int32_t last_width = -1;
3642 7997 int32_t width = itemsbuf[current_item_id(itype_lens,true)].misc1;
3643
3644 // Only redraw the circle if the size has changed
3645
2/2
✓ Branch 0 taken 7992 times.
✓ Branch 1 taken 5 times.
7997 if(width != last_width)
3646 {
3647
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(lens_scr == NULL)
3648 {
3649 5 lens_scr = create_bitmap_ex(8,2*288,2*(240-playing_field_offset));
3650 5 }
3651
3652 5 clear_to_color(lens_scr, BLACK);
3653 5 circlefill(lens_scr, 288, 240-playing_field_offset, width, 0);
3654 5 circle(lens_scr, 288, 240-playing_field_offset, width+2, 0);
3655 5 circle(lens_scr, 288, 240-playing_field_offset, width+5, 0);
3656 5 last_width=width;
3657 5 }
3658
3659 7997 masked_blit(lens_scr, framebuf, 288-(HeroX()+8), 240-playing_field_offset-(HeroY()+8), 0, playing_field_offset, 256, 168);
3660 7997 }
3661
3662 //----------------------------------------------------------------
3663
3664 30701 void draw_wavy(BITMAP *source, BITMAP *target, int32_t amplitude, bool interpol)
3665 {
3666 //recreating a big bitmap every frame is highly sluggish.
3667
4/6
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 30699 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
30701 static BITMAP *wavebuf = create_bitmap_ex(8,288,240-original_playing_field_offset);
3668 30701 clear_to_color(wavebuf, BLACK);
3669 30701 blit(source,wavebuf,0,original_playing_field_offset,16,0,256,224-original_playing_field_offset);
3670
3671 int32_t ofs;
3672 // int32_t amplitude=8;
3673 // int32_t wavelength=4;
3674
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30701 times.
30701 amplitude = zc_min(2048,amplitude); // some arbitrary limit to prevent crashing
3675
3/6
✓ Branch 0 taken 30701 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 30701 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 30701 times.
30701 if(flash_reduction_enabled() && !get_bit(quest_rules, qr_WAVY_NO_EPILEPSY)) amplitude = zc_min(16,amplitude);
3676 30701 int32_t amp2=168;
3677
2/4
✓ Branch 0 taken 30701 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 30701 times.
30701 if(flash_reduction_enabled() && !get_bit(quest_rules, qr_WAVY_NO_EPILEPSY_2)) amp2*=2;
3678 30701 int32_t i=frame%amp2;
3679
3680
2/2
✓ Branch 0 taken 5157768 times.
✓ Branch 1 taken 30701 times.
5188469 for(int32_t j=0; j<168; j++)
3681 {
3682
3/4
✓ Branch 0 taken 2578884 times.
✓ Branch 1 taken 2578884 times.
✓ Branch 2 taken 2578884 times.
✗ Branch 3 not taken.
5157768 if(j&1 && interpol)
3683 {
3684 // Add 288*2048 to ensure it's never negative. It'll get modded out.
3685 ofs=288*2048+int32_t(zc::math::Sin((double(i+j)*2*PI/amp2))*amplitude);
3686 }
3687 else
3688 {
3689 5157768 ofs=288*2048-int32_t(zc::math::Sin((double(i+j)*2*PI/amp2))*amplitude);
3690 }
3691
3692
1/2
✓ Branch 0 taken 5157768 times.
✗ Branch 1 not taken.
5157768 if(ofs)
3693 {
3694
2/2
✓ Branch 0 taken 1320388608 times.
✓ Branch 1 taken 5157768 times.
1325546376 for(int32_t k=0; k<256; k++)
3695 {
3696 1320388608 target->line[j+original_playing_field_offset][k]=wavebuf->line[j][(k+ofs+16)%288];
3697 1320388608 }
3698 5157768 }
3699 5157768 }
3700 30701 }
3701
3702 2832 void draw_fuzzy(int32_t fuzz)
3703 // draws from right half of scrollbuf to framebuf
3704 {
3705 int32_t firstx, firsty, xstep, ystep, i, y, dx, dy;
3706 byte *start, *si, *di;
3707
3708
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2832 times.
2832 if(fuzz<1)
3709 fuzz = 1;
3710
3711 2832 xstep = 128%fuzz;
3712
3713
2/2
✓ Branch 0 taken 590 times.
✓ Branch 1 taken 2242 times.
2832 if(xstep > 0)
3714 2242 xstep = fuzz-xstep;
3715
3716 2832 ystep = 112%fuzz;
3717
3718
2/2
✓ Branch 0 taken 826 times.
✓ Branch 1 taken 2006 times.
2832 if(ystep > 0)
3719 2006 ystep = fuzz-ystep;
3720
3721 2832 firsty = 1;
3722
3723
2/2
✓ Branch 0 taken 2832 times.
✓ Branch 1 taken 102188 times.
105020 for(y=0; y<224;)
3724 {
3725 102188 start = &(scrollbuf->line[y][256]);
3726
3727
4/4
✓ Branch 0 taken 100772 times.
✓ Branch 1 taken 635784 times.
✓ Branch 2 taken 634368 times.
✓ Branch 3 taken 102188 times.
736556 for(dy=0; dy<ystep && dy+y<224; dy++)
3728 {
3729 634368 si = start;
3730 634368 di = &(framebuf->line[y+dy][0]);
3731 634368 i = xstep;
3732 634368 firstx = 1;
3733
3734
2/2
✓ Branch 0 taken 162398208 times.
✓ Branch 1 taken 634368 times.
163032576 for(dx=0; dx<256; dx++)
3735 {
3736 162398208 *(di++) = *si;
3737
3738
2/2
✓ Branch 0 taken 136838464 times.
✓ Branch 1 taken 25559744 times.
162398208 if(++i >= fuzz)
3739 {
3740
2/2
✓ Branch 0 taken 24925376 times.
✓ Branch 1 taken 634368 times.
25559744 if(!firstx)
3741 24925376 si += fuzz;
3742 else
3743 {
3744 634368 si += fuzz-xstep;
3745 634368 firstx = 0;
3746 }
3747
3748 25559744 i = 0;
3749 25559744 }
3750 162398208 }
3751 634368 }
3752
3753
2/2
✓ Branch 0 taken 99356 times.
✓ Branch 1 taken 2832 times.
102188 if(!firsty)
3754 99356 y += fuzz;
3755 else
3756 {
3757 2832 y += ystep;
3758 2832 ystep = fuzz;
3759 2832 firsty = 0;
3760 }
3761 }
3762 2832 }
3763
3764 6510665 void updatescr(bool allowwavy)
3765 {
3766
4/6
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 6510636 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 29 times.
✓ Branch 4 taken 29 times.
✗ Branch 5 not taken.
6510665 static BITMAP *wavybuf = create_bitmap_ex(8,256,224);
3767
4/6
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 6510636 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 29 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 29 times.
6510665 static BITMAP *panorama = create_bitmap_ex(8,256,224);
3768
3769
2/2
✓ Branch 0 taken 6484961 times.
✓ Branch 1 taken 25704 times.
6510665 if(toogam)
3770 {
3771 25704 textout_ex(framebuf,font,"no walls",8,216,1,-1);
3772 25704 }
3773
3774
1/2
✓ Branch 0 taken 6510665 times.
✗ Branch 1 not taken.
6510665 if(Showpal)
3775 dump_pal(framebuf);
3776
3777
2/2
✓ Branch 0 taken 6428643 times.
✓ Branch 1 taken 82022 times.
6510665 if(!Playing)
3778 82022 black_opening_count=0;
3779
3780
2/2
✓ Branch 0 taken 6472715 times.
✓ Branch 1 taken 37950 times.
6510665 if(black_opening_count<0) //shape is opening up
3781 {
3782 37950 black_opening(framebuf,black_opening_x,black_opening_y,(66+black_opening_count),66);
3783
3784
2/4
✓ Branch 0 taken 37950 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 37950 times.
37950 if(Advance||(!Paused))
3785 {
3786 37950 ++black_opening_count;
3787 37950 }
3788 37950 }
3789
2/2
✓ Branch 0 taken 6458459 times.
✓ Branch 1 taken 14256 times.
6472715 else if(black_opening_count>0) //shape is closing
3790 {
3791 14256 black_opening(framebuf,black_opening_x,black_opening_y,black_opening_count,66);
3792
3793
2/4
✓ Branch 0 taken 14256 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 14256 times.
14256 if(Advance||(!Paused))
3794 {
3795 14256 --black_opening_count;
3796 14256 }
3797 14256 }
3798
3799
3/4
✓ Branch 0 taken 6459250 times.
✓ Branch 1 taken 51415 times.
✓ Branch 2 taken 6459250 times.
✗ Branch 3 not taken.
6510665 if(black_opening_count==0&&black_opening_shape==bosFADEBLACK)
3800 {
3801 black_opening_shape = bosCIRCLE;
3802 memcpy(RAMpal, tempblackpal, PAL_SIZE*sizeof(RGB));
3803 refreshTints();
3804 refreshpal=true;
3805 }
3806
3807
2/2
✓ Branch 0 taken 6298112 times.
✓ Branch 1 taken 212553 times.
6510665 if(refreshpal)
3808 {
3809 212553 refreshpal=false;
3810 212553 RAMpal[253] = _RGB(0,0,0);
3811 212553 RAMpal[254] = _RGB(63,63,63);
3812 212553 hw_palette = &RAMpal;
3813 212553 update_hw_pal = true;
3814
3815 212553 create_rgb_table(&rgb_table, RAMpal, NULL);
3816 212553 create_zc_trans_table(&trans_table, RAMpal, 128, 128, 128);
3817 212553 memcpy(&trans_table2, &trans_table, sizeof(COLOR_MAP));
3818
3819
2/2
✓ Branch 0 taken 54413568 times.
✓ Branch 1 taken 212553 times.
54626121 for(int32_t q=0; q<PAL_SIZE; q++)
3820 {
3821 54413568 trans_table2.data[0][q] = q;
3822 54413568 trans_table2.data[q][q] = q;
3823 54413568 }
3824 212553 }
3825
3826 6510665 bool clearwavy = (wavy <= 0);
3827
3828
2/2
✓ Branch 0 taken 7245 times.
✓ Branch 1 taken 6503420 times.
6510665 if(wavy <= 0)
3829 {
3830 // So far one thing can alter wavy apart from scripts: Wavy DMaps.
3831 6503420 wavy = (DMaps[currdmap].flags&dmfWAVY ? 4 : 0);
3832 6503420 }
3833
3834 6510665 blit(framebuf, wavybuf, 0, 0, 0, 0, 256, 224);
3835
3836
6/6
✓ Branch 0 taken 30951 times.
✓ Branch 1 taken 6479714 times.
✓ Branch 2 taken 30829 times.
✓ Branch 3 taken 122 times.
✓ Branch 4 taken 128 times.
✓ Branch 5 taken 30701 times.
6510665 if(wavy && Playing && allowwavy)
3837 {
3838 30701 draw_wavy(framebuf, wavybuf, wavy,false);
3839 30701 }
3840
3841
2/2
✓ Branch 0 taken 6503420 times.
✓ Branch 1 taken 7245 times.
6510665 if(clearwavy)
3842 6503420 wavy = 0; // Wavy was set by a DMap flag. Clear it.
3843
2/4
✓ Branch 0 taken 7245 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 7245 times.
7245 else if(Playing && !Paused)
3844 7245 wavy--; // Wavy was set by a script. Decrement it.
3845
3846
5/6
✓ Branch 0 taken 6428643 times.
✓ Branch 1 taken 82022 times.
✓ Branch 2 taken 125857 times.
✓ Branch 3 taken 6302786 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 125857 times.
6510665 if(Playing && msgpos && !screenscrolling)
3847 {
3848
1/2
✓ Branch 0 taken 125857 times.
✗ Branch 1 not taken.
125857 if(!(msg_bg_display_buf->clip))
3849 125857 blit_msgstr_bg(framebuf,0,0,0,playing_field_offset,256,168);
3850
1/2
✓ Branch 0 taken 125857 times.
✗ Branch 1 not taken.
125857 if(!(msg_portrait_display_buf->clip))
3851 125857 blit_msgstr_prt(framebuf,0,0,0,playing_field_offset,256,168);
3852
1/2
✓ Branch 0 taken 125857 times.
✗ Branch 1 not taken.
125857 if(!(msg_txt_display_buf->clip))
3853 125857 blit_msgstr_fg(framebuf,0,0,0,playing_field_offset,256,168);
3854 125857 }
3855
3856 /*
3857 if(!(msg_txt_display_buf->clip) && Playing && msgpos && !screenscrolling)
3858 {
3859 BITMAP* subBmp = 0;
3860 masked_blit(msg_txt_display_buf,subBmp,0,0,0,playing_field_offset,256,168);
3861 // masked_blit(msg_txt_display_buf,subBmp,0,playing_field_offset,256,168);
3862 draw_trans_sprite(framebuf, subBmp, 0, playing_field_offset);
3863 destroy_bitmap(subBmp);
3864 //void draw_sprite_ex(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t mode, int32_t flip);
3865 // masked_blit(msg_txt_display_buf,framebuf,0,0,0,playing_field_offset,256,168);
3866 //void masked_blit(BITMAP *source, BITMAP *dest, int32_t source_x, int32_t source_y, int32_t dest_x, int32_t dest_y, int32_t width, int32_t height);
3867 }
3868 */
3869
3870
2/2
✓ Branch 0 taken 6485486 times.
✓ Branch 1 taken 25179 times.
6510665 bool nosubscr = (tmpscr->flags3&fNOSUBSCR && !(tmpscr->flags3&fNOSUBSCROFFSET));
3871
3872
2/2
✓ Branch 0 taken 6485486 times.
✓ Branch 1 taken 25179 times.
6510665 if(nosubscr)
3873 {
3874 25179 rectfill(panorama,0,0,255,passive_subscreen_height/2,0);
3875 25179 rectfill(panorama,0,168+passive_subscreen_height/2,255,168+passive_subscreen_height-1,0);
3876 25179 blit(wavybuf,panorama,0,playing_field_offset,0,passive_subscreen_height/2,256,224-passive_subscreen_height);
3877 25179 }
3878
3879 //TODO: Optimize blit 'overcalls' -Gleeok
3880
2/2
✓ Branch 0 taken 25179 times.
✓ Branch 1 taken 6485486 times.
6510665 BITMAP *source = nosubscr ? panorama : wavybuf;
3881 6510665 blit(source,framebuf,0,0,0,0,256,224);
3882
3883 6510665 update_hw_screen();
3884 6510665 }
3885
3886 //----------------------------------------------------------------
3887
3888 PALETTE sys_pal;
3889
3890 int32_t onGUISnapshot()
3891 {
3892 char buf[200];
3893 int32_t num=0;
3894 bool realpal=(key[KEY_ZC_LCONTROL] || key[KEY_ZC_RCONTROL]);
3895 do
3896 {
3897 sprintf(buf, "%szc_screen%05d.%s", get_snap_str(), ++num, snapshotformat_str[SnapshotFormat][1]);
3898 }
3899 while(num<99999 && exists(buf));
3900
3901 BITMAP *b = create_bitmap_ex(8,resx,resy);
3902
3903 if(b)
3904 {
3905 if(MenuOpen)
3906 {
3907 //Cannot load game's palette while GUI elements are in focus. -Z
3908 //If there is a way to do this, then I have missed it.
3909 /*
3910 game_pal();
3911 RAMpal[253] = _RGB(0,0,0);
3912 RAMpal[254] = _RGB(63,63,63);
3913 set_palette_range(RAMpal,0,255,false);
3914 memcpy(RAMpal, snappal, sizeof(snappal));
3915 create_rgb_table(&rgb_table, RAMpal, NULL);
3916 create_zc_trans_table(&trans_table, RAMpal, 128, 128, 128);
3917 memcpy(&trans_table2, &trans_table, sizeof(COLOR_MAP));
3918
3919 for(int32_t q=0; q<PAL_SIZE; q++)
3920 {
3921 trans_table2.data[0][q] = q;
3922 trans_table2.data[q][q] = q;
3923 }
3924 */
3925 //ringcolor(false);
3926 //get_palette(RAMpal);
3927 blit(screen,b,0,0,0,0,resx,resy);
3928 //al_trace("Menu Open\n");
3929 //game_pal();
3930 //PALETTE temppal;
3931 //get_palette(temppal);
3932 //system_pal();
3933 save_bitmap(buf,b,sys_pal);
3934 //save_bitmap(buf,b,RAMpal);
3935 //save_bitmap(buf,b,snappal);
3936 }
3937 else
3938 {
3939 blit(screen,b,0,0,0,0,resx,resy);
3940 save_bitmap(buf,b,realpal?sys_pal:RAMpal);
3941 }
3942 destroy_bitmap(b);
3943 }
3944
3945 return D_O_K;
3946 }
3947
3948 int32_t onNonGUISnapshot()
3949 {
3950 PALETTE temppal;
3951 get_palette(temppal);
3952 bool realpal=(zc_getkey(KEY_ZC_LCONTROL, true) || zc_getkey(KEY_ZC_RCONTROL, true));
3953
3954 char buf[200];
3955 int32_t num=0;
3956
3957 do
3958 {
3959 sprintf(buf, "%szc_screen%05d.%s", get_snap_str(), ++num, snapshotformat_str[SnapshotFormat][1]);
3960 }
3961 while(num<99999 && exists(buf));
3962
3963 save_bitmap(buf,framebuf,realpal?temppal:RAMpal);
3964
3965 return D_O_K;
3966 }
3967
3968 int32_t onSnapshot()
3969 {
3970 if(zc_getkey(KEY_LSHIFT, true)||zc_getkey(KEY_RSHIFT, true))
3971 {
3972 onGUISnapshot();
3973 }
3974 else
3975 {
3976 onNonGUISnapshot();
3977 }
3978
3979 return D_O_K;
3980 }
3981
3982 int32_t onSaveMapPic()
3983 {
3984 int32_t mapres2 = 0;
3985 char buf[200];
3986 int32_t num=0;
3987 mapscr tmpscr_b[2];
3988 mapscr tmpscr_c[6];
3989 BITMAP* _screen_draw_buffer = NULL;
3990 _screen_draw_buffer = create_bitmap_ex(8,256,224);
3991 set_clip_state(_screen_draw_buffer,1);
3992
3993 for(int32_t i=0; i<6; ++i)
3994 {
3995 tmpscr_c[i] = tmpscr2[i];
3996 tmpscr2[i].zero_memory();
3997
3998 if(i>=2)
3999 {
4000 continue;
4001 }
4002
4003 tmpscr_b[i] = tmpscr[i];
4004 tmpscr[i].zero_memory();
4005 }
4006
4007 do
4008 {
4009 sprintf(buf, "%szc_screen%05d.png", get_snap_str(), ++num);
4010 }
4011 while(num<99999 && exists(buf));
4012
4013 BITMAP* mappic = NULL;
4014
4015
4016 bool done=false, redraw=true;
4017
4018 mappic = create_bitmap_ex(8,(256*16)>>mapres,(176*8)>>mapres);
4019
4020 if(!mappic)
4021 {
4022 system_pal();
4023 jwin_alert("View Map","Not enough memory.",NULL,NULL,"OK",NULL,13,27,lfont);
4024 game_pal();
4025 return D_O_K;;
4026 }
4027
4028 // draw the map
4029 set_clip_rect(_screen_draw_buffer, 0, 0, _screen_draw_buffer->w, _screen_draw_buffer->h);
4030
4031 for(int32_t y=0; y<8; y++)
4032 {
4033 for(int32_t x=0; x<16; x++)
4034 {
4035 if(!displayOnMap(x, y))
4036 {
4037 rectfill(_screen_draw_buffer, 0, 0, 255, 223, WHITE);
4038 }
4039 else
4040 {
4041 int32_t s = (y<<4) + x;
4042 loadscr2(1,s,-1);
4043
4044 for(int32_t i=0; i<6; i++)
4045 {
4046 if(tmpscr[1].layermap[i]<=0)
4047 continue;
4048
4049 if((ZCMaps[tmpscr[1].layermap[i]-1].tileWidth==ZCMaps[currmap].tileWidth) &&
4050 (ZCMaps[tmpscr[1].layermap[i]-1].tileHeight==ZCMaps[currmap].tileHeight))
4051 {
4052 const int32_t _mapsSize = (ZCMaps[currmap].tileWidth)*(ZCMaps[currmap].tileHeight);
4053
4054 tmpscr2[i]=TheMaps[(tmpscr[1].layermap[i]-1)*MAPSCRS+tmpscr[1].layerscreen[i]];
4055 }
4056 }
4057
4058 if(XOR((tmpscr+1)->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(_screen_draw_buffer, 0, 2, tmpscr+1, -256, playing_field_offset, 2);
4059
4060 if(XOR((tmpscr+1)->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(_screen_draw_buffer, 0, 3, tmpscr+1, -256, playing_field_offset, 2);
4061
4062 putscr(_screen_draw_buffer,256,0,tmpscr+1);
4063 do_layer(_screen_draw_buffer, 0, 1, tmpscr+1, -256, playing_field_offset, 2);
4064
4065 if(!XOR((tmpscr+1)->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(_screen_draw_buffer, 0, 2, tmpscr+1, -256, playing_field_offset, 2);
4066
4067 putscrdoors(_screen_draw_buffer,256,0,tmpscr+1);
4068 do_layer(_screen_draw_buffer, -2, 0, tmpscr+1, -256, playing_field_offset, 2);
4069 if(get_bit(quest_rules, qr_PUSHBLOCK_LAYER_1_2))
4070 {
4071 do_layer(_screen_draw_buffer, -2, 1, tmpscr+1, -256, playing_field_offset, 2);
4072 do_layer(_screen_draw_buffer, -2, 2, tmpscr+1, -256, playing_field_offset, 2);
4073 }
4074 do_layer(_screen_draw_buffer, -3, 0, tmpscr+1, -256, playing_field_offset, 2); // Freeform combos!
4075
4076 if(!XOR((tmpscr+1)->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(_screen_draw_buffer, 0, 3, tmpscr+1, -256, playing_field_offset, 2);
4077
4078 do_layer(_screen_draw_buffer, 0, 4, tmpscr+1, -256, playing_field_offset, 2);
4079 do_layer(_screen_draw_buffer, -1, 0, tmpscr+1, -256, playing_field_offset, 2);
4080 if(get_bit(quest_rules, qr_OVERHEAD_COMBOS_L1_L2))
4081 {
4082 do_layer(_screen_draw_buffer, -1, 1, tmpscr+1, -256, playing_field_offset, 2);
4083 do_layer(_screen_draw_buffer, -1, 2, tmpscr+1, -256, playing_field_offset, 2);
4084 }
4085 do_layer(_screen_draw_buffer, 0, 5, tmpscr+1, -256, playing_field_offset, 2);
4086 do_layer(_screen_draw_buffer, 0, 6, tmpscr+1, -256, playing_field_offset, 2);
4087
4088 }
4089
4090 stretch_blit(_screen_draw_buffer, mappic, 256, 0, 256, 176, x<<(8-mapres), (y*176)>>mapres, 256>>mapres, 176>>mapres);
4091 }
4092 }
4093
4094 for(int32_t i=0; i<6; ++i)
4095 {
4096 tmpscr2[i]=tmpscr_c[i];
4097
4098 if(i>=2)
4099 {
4100 continue;
4101 }
4102
4103 tmpscr[i]=tmpscr_b[i];
4104 }
4105
4106 save_bitmap(buf,mappic,RAMpal);
4107 destroy_bitmap(mappic);
4108 destroy_bitmap(_screen_draw_buffer);
4109 return D_O_K;
4110 }
4111
4112 /*
4113 int32_t onSaveMapPic()
4114 {
4115 BITMAP* mappic = NULL;
4116 BITMAP* _screen_draw_buffer = NULL;
4117 _screen_draw_buffer = create_bitmap_ex(8,256,224);
4118 int32_t mapres2 = 0;
4119 char buf[20];
4120 int32_t num=0;
4121 set_clip_state(_screen_draw_buffer,1);
4122 set_clip_rect(_screen_draw_buffer,0,0,_screen_draw_buffer->w, _screen_draw_buffer->h);
4123
4124 do
4125 {
4126 sprintf(buf, "zelda%03d.png", ++num);
4127 }
4128 while(num<999 && exists(buf));
4129
4130 // if(!mappic) {
4131 mappic = create_bitmap_ex(8,(256*16)>>mapres2,(176*8)>>mapres2);
4132
4133 if(!mappic)
4134 {
4135 system_pal();
4136 jwin_alert("Save Map Picture","Not enough memory.",NULL,NULL,"OK",NULL,13,27,lfont);
4137 game_pal();
4138 return D_O_K;
4139 }
4140
4141 // }
4142
4143 int32_t layermap, layerscreen;
4144 int32_t x2=0;
4145
4146 // draw the map
4147 for(int32_t y=0; y<8; y++)
4148 {
4149 for(int32_t x=0; x<16; x++)
4150 {
4151 int32_t s = (y<<4) + x;
4152
4153 if(!displayOnMap(x, y))
4154 {
4155 rectfill(_screen_draw_buffer, 0, 0, 255, 223, WHITE);
4156 }
4157 else
4158 {
4159 loadscr(TEMPSCR_FUNCTION_SWAP_SPACE,currdmap,s,-1,false);
4160 putscr(_screen_draw_buffer, 0, 0, tmpscr+1);
4161
4162 for(int32_t k=0; k<4; k++)
4163 {
4164 if(k==2)
4165 {
4166 putscrdoors(_screen_draw_buffer, 0, 0, tmpscr+1);
4167 }
4168
4169 layermap=TheMaps[currmap*MAPSCRS+s].layermap[k]-1;
4170
4171 if(layermap>-1)
4172 {
4173 layerscreen=layermap*MAPSCRS+TheMaps[currmap*MAPSCRS+s].layerscreen[k];
4174
4175 if(TheMaps[currmap*MAPSCRS+s].layeropacity[k]==255)
4176 {
4177 for(int32_t i=0; i<176; i++)
4178 {
4179 overcombo(_screen_draw_buffer,((i&15)<<4)+x2,(i&0xF0),TheMaps[layerscreen].data[i],TheMaps[layerscreen].cset[i]);
4180 }
4181 }
4182 else
4183 {
4184 for(int32_t i=0; i<176; i++)
4185 {
4186 overcombotranslucent(_screen_draw_buffer,((i&15)<<4)+x2,(i&0xF0),TheMaps[layerscreen].data[i],TheMaps[layerscreen].cset[i],TheMaps[currmap*MAPSCRS+s].layeropacity[k]);
4187 }
4188 }
4189 }
4190 }
4191
4192 for(int32_t i=0; i<176; i++)
4193 {
4194 // if (COMBOTYPE((i&15)<<4,i&0xF0)==cOLD_OVERHEAD)
4195 if(combo_class_buf[COMBOTYPE((i&15)<<4,i&0xF0)].overhead)
4196 {
4197 overcombo(_screen_draw_buffer,((i&15)<<4)+x2,(i&0xF0),MAPCOMBO((i&15)<<4,i&0xF0),MAPCSET((i&15)<<4,i&0xF0));
4198 }
4199 }
4200
4201 for(int32_t k=4; k<6; k++)
4202 {
4203 layermap=TheMaps[currmap*MAPSCRS+s].layermap[k]-1;
4204
4205 if(layermap>-1)
4206 {
4207 layerscreen=layermap*MAPSCRS+TheMaps[currmap*MAPSCRS+s].layerscreen[k];
4208
4209 if(TheMaps[currmap*MAPSCRS+s].layeropacity[k]==255)
4210 {
4211 for(int32_t i=0; i<176; i++)
4212 {
4213 overcombo(_screen_draw_buffer,((i&15)<<4)+x2,(i&0xF0),TheMaps[layerscreen].data[i],TheMaps[layerscreen].cset[i]);
4214 }
4215 }
4216 else
4217 {
4218 for(int32_t i=0; i<176; i++)
4219 {
4220 overcombotranslucent(_screen_draw_buffer,((i&15)<<4)+x2,(i&0xF0),TheMaps[layerscreen].data[i],TheMaps[layerscreen].cset[i],TheMaps[currmap*MAPSCRS+s].layeropacity[k]);
4221 }
4222 }
4223 }
4224 }
4225 }
4226
4227 stretch_blit(_screen_draw_buffer, mappic, 0, 0, 256, 176,
4228 x<<(8-mapres2), (y*176)>>mapres2, 256>>mapres2, 176>>mapres2);
4229 }
4230
4231 }
4232
4233 save_bitmap(buf,mappic,RAMpal);
4234 destroy_bitmap(mappic);
4235 destroy_bitmap(_screen_draw_buffer);
4236 return D_O_K;
4237 }
4238 */
4239
4240 14 void f_Quit(int32_t type)
4241 {
4242
2/4
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
14 if(type==qQUIT && !Playing)
4243 return;
4244
4245 14 bool from_menu = is_sys_pal;
4246
4247
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(!from_menu)
4248 {
4249 14 music_pause();
4250 14 pause_all_sfx();
4251 14 }
4252 14 enter_sys_pal();
4253 14 clear_keybuf();
4254
4255
2/4
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 14 times.
14 if (replay_is_active() && replay_get_version() <= 9)
4256 14 replay_poll();
4257
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if (replay_is_replaying())
4258 14 replay_peek_quit();
4259
4260
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
14 if (!replay_is_replaying())
4261 switch(type)
4262 {
4263 case qQUIT:
4264 onQuit();
4265 break;
4266
4267 case qRESET:
4268 onReset();
4269 break;
4270
4271 case qEXIT:
4272 onExit();
4273 break;
4274 }
4275
4276
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
14 if(Quit)
4277 {
4278 14 kill_sfx();
4279 14 music_stop();
4280 14 exit_sys_pal();
4281 14 update_hw_screen();
4282 14 }
4283 else
4284 {
4285 exit_sys_pal();
4286 if(!from_menu)
4287 {
4288 music_resume();
4289 resume_all_sfx();
4290 }
4291 }
4292
4293
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(!from_menu)
4294 14 show_mouse(NULL);
4295 14 eat_buttons();
4296
4297 14 zc_readrawkey(KEY_ESC);
4298
4299 14 zc_readrawkey(KEY_ENTER);
4300 14 }
4301
4302 //----------------------------------------------------------------
4303
4304 int32_t onNoWalls()
4305 {
4306 cheats_enqueue(Cheat::Walls);
4307 return D_O_K;
4308 }
4309
4310 int32_t onIgnoreSideview()
4311 {
4312 cheats_enqueue(Cheat::IgnoreSideView);
4313 return D_O_K;
4314 }
4315
4316 6510614 int32_t input_idle(bool checkmouse)
4317 {
4318 static int32_t mx, my, mz, mb;
4319
4320
4/6
✓ Branch 0 taken 6510614 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1621032 times.
✓ Branch 3 taken 4889582 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1621032 times.
8131646 if(keypressed() || zc_key_pressed() ||
4321
4/8
✓ Branch 0 taken 1621032 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1621032 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1621032 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1621032 times.
✗ Branch 7 not taken.
1621032 (checkmouse && (mx != mouse_x || my != mouse_y || mz != mouse_z || mb != mouse_b)))
4322 {
4323 4889582 idle_count = 0;
4324
4325
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4889582 times.
4889582 if(active_count < MAX_ACTIVE)
4326 {
4327 4889582 ++active_count;
4328 4889582 }
4329 4889582 }
4330
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1621032 times.
1621032 else if(idle_count < MAX_IDLE)
4331 {
4332 1621032 ++idle_count;
4333 1621032 active_count = 0;
4334 1621032 }
4335
4336 6510614 mx = mouse_x;
4337 6510614 my = mouse_y;
4338 6510614 mz = mouse_z;
4339 6510614 mb = mouse_b;
4340
4341 6510614 return idle_count;
4342 }
4343
4344 int32_t onGoFast()
4345 {
4346 cheats_enqueue(Cheat::Fast);
4347 return D_O_K;
4348 }
4349
4350 int32_t onKillCheat()
4351 {
4352 cheats_enqueue(Cheat::Kill);
4353 return D_O_K;
4354 }
4355
4356 int32_t onSecretsCheat()
4357 {
4358 cheats_enqueue(Cheat::TrigSecrets);
4359 return D_O_K;
4360 }
4361 int32_t onSecretsCheatPerm()
4362 {
4363 cheats_enqueue(Cheat::TrigSecretsPerm);
4364 return D_O_K;
4365 }
4366
4367 int32_t onShowLayer0()
4368 {
4369 show_layer_0 = !show_layer_0;
4370 return D_O_K;
4371 }
4372 int32_t onShowLayer1()
4373 {
4374 show_layer_1 = !show_layer_1;
4375 return D_O_K;
4376 }
4377 int32_t onShowLayer2()
4378 {
4379 show_layer_2 = !show_layer_2;
4380 return D_O_K;
4381 }
4382 int32_t onShowLayer3()
4383 {
4384 show_layer_3 = !show_layer_3;
4385 return D_O_K;
4386 }
4387 int32_t onShowLayer4()
4388 {
4389 show_layer_4 = !show_layer_4;
4390 return D_O_K;
4391 }
4392 int32_t onShowLayer5()
4393 {
4394 show_layer_5 = !show_layer_5;
4395 return D_O_K;
4396 }
4397 int32_t onShowLayer6()
4398 {
4399 show_layer_6 = !show_layer_6;
4400 return D_O_K;
4401 }
4402 int32_t onShowLayerO()
4403 {
4404 show_layer_over=!show_layer_over;
4405 return D_O_K;
4406 }
4407 int32_t onShowLayerP()
4408 {
4409 show_layer_push=!show_layer_push;
4410 return D_O_K;
4411 }
4412 int32_t onShowLayerS()
4413 {
4414 show_sprites=!show_sprites;
4415 return D_O_K;
4416 }
4417 int32_t onShowLayerF()
4418 {
4419 show_ffcs=!show_ffcs;
4420 return D_O_K;
4421 }
4422 int32_t onShowLayerW()
4423 {
4424 show_walkflags=!show_walkflags;
4425 if(show_walkflags)
4426 show_effectflags = false;
4427 return D_O_K;
4428 }
4429 int32_t onShowLayerE()
4430 {
4431 show_effectflags=!show_effectflags;
4432 if(show_effectflags)
4433 show_walkflags = false;
4434 return D_O_K;
4435 }
4436 int32_t onShowFFScripts()
4437 {
4438 show_ff_scripts=!show_ff_scripts;
4439 return D_O_K;
4440 }
4441 int32_t onShowHitboxes()
4442 {
4443 show_hitboxes=!show_hitboxes;
4444 return D_O_K;
4445 }
4446 int32_t onShowInfoOpacity()
4447 {
4448 info_opacity = vbound(getnumber("Debug Info Opacity",info_opacity),0,255);
4449 zc_set_config("zc","debug_info_opacity",info_opacity);
4450 return D_O_K;
4451 }
4452
4453 int32_t onLightSwitch()
4454 {
4455 cheats_enqueue(Cheat::Light);
4456 return D_O_K;
4457 }
4458
4459 int32_t onGoTo();
4460 int32_t onGoToComplete();
4461
4462 6510614 void syskeys()
4463 {
4464 6510614 update_system_keys();
4465
4466 int32_t oldtitle_version;
4467
4468
1/2
✓ Branch 0 taken 6510614 times.
✗ Branch 1 not taken.
6510614 if(close_button_quit)
4469 {
4470 close_button_quit=false;
4471 f_Quit(qEXIT);
4472 }
4473
4474 6510614 poll_joystick();
4475
4476
2/10
✓ Branch 0 taken 6510614 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6510614 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
6510614 if(rMbtn() || (gui_mouse_b() && !mouse_down && ClickToFreeze &&!disableClickToFreeze))
4477 {
4478 oldtitle_version=title_version;
4479 System();
4480 }
4481
4482 6510614 mouse_down=gui_mouse_b();
4483
4484
1/2
✓ Branch 0 taken 6510614 times.
✗ Branch 1 not taken.
6510614 if(zc_read_system_key(KEY_F1))
4485 {
4486 if(zc_get_system_key(KEY_ZC_LCONTROL) || zc_get_system_key(KEY_ZC_RCONTROL))
4487 {
4488 halt=!halt;
4489 //zinit.subscreen=(zinit.subscreen+1)%ssdtMAX;
4490 }
4491 else
4492 {
4493 Throttlefps=!Throttlefps;
4494 zc_set_config(cfg_sect,"throttlefps", (int32_t)Throttlefps);
4495 logic_counter=0;
4496 }
4497 }
4498
4499 // if(zc_readkey(KEY_F1)) Vsync=!Vsync;
4500 /*
4501 if(zc_readkey(KEY_F1)) set_bit(QHeader.rules4,qr4_NEWENEMYTILES,
4502 1-((get_bit(QHeader.rules4,qr4_NEWENEMYTILES))));
4503 */
4504
4505
1/2
✓ Branch 0 taken 6510614 times.
✗ Branch 1 not taken.
6510614 if(zc_read_system_key(KEY_F2))
4506 {
4507 ShowFPS=!ShowFPS;
4508 zc_set_config(cfg_sect,"showfps",(int32_t)ShowFPS);
4509 }
4510
4511
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6510614 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6510614 if(zc_read_system_key(KEY_F3) && Playing) Paused=!Paused;
4512
4513
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6510614 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6510614 if(zc_read_system_key(KEY_F4) && Playing)
4514 {
4515 Paused=true;
4516 Advance=true;
4517 }
4518
4519
1/2
✓ Branch 0 taken 6510614 times.
✗ Branch 1 not taken.
6510614 if(zc_read_system_key(KEY_F6)) onTryQuit();
4520
4521 #ifndef ALLEGRO_MACOSX
4522
1/2
✓ Branch 0 taken 6510614 times.
✗ Branch 1 not taken.
6510614 if(zc_read_system_key(KEY_F9)) f_Quit(qRESET);
4523
4524
1/2
✓ Branch 0 taken 6510614 times.
✗ Branch 1 not taken.
6510614 if(zc_read_system_key(KEY_F10)) f_Quit(qEXIT);
4525 #else
4526 if(zc_read_system_key(KEY_F7)) f_Quit(qRESET);
4527
4528 if(zc_read_system_key(KEY_F8)) f_Quit(qEXIT);
4529 #endif
4530
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 6510614 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
6510614 if(zc_read_system_key(KEY_F5)&&(Playing && currscr<128 && DMaps[currdmap].flags&dmfVIEWMAP)) onSaveMapPic();
4531
4532
1/2
✓ Branch 0 taken 6510614 times.
✗ Branch 1 not taken.
6510614 if (zc_read_system_key(KEY_F12))
4533 {
4534 onSnapshot();
4535 }
4536
4537
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6510614 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6510614 if(debug_enabled && zc_read_system_key(KEY_TAB))
4538 set_debug(!get_debug());
4539
4540
1/2
✓ Branch 0 taken 6510614 times.
✗ Branch 1 not taken.
6510614 if(CheatModifierKeys())
4541 {
4542 for(Cheat c = (Cheat)1; c < Cheat::Last; c = (Cheat)(c+1))
4543 {
4544 if(!bindable_cheat(c))
4545 continue;
4546 if(get_debug() || cheat >= cheat_lvl(c))
4547 {
4548 if(checkcheat(c))
4549 cheats_hit_bind(c);
4550 }
4551 }
4552 }
4553
4554
1/2
✓ Branch 0 taken 6510614 times.
✗ Branch 1 not taken.
6510614 if(volkeys)
4555 {
4556 if(zc_read_system_key(KEY_PGUP)) master_volume(-1,midi_volume+8);
4557
4558 if(zc_read_system_key(KEY_PGDN)) master_volume(-1,midi_volume==255?248:midi_volume-8);
4559
4560 if(zc_read_system_key(KEY_HOME)) master_volume(digi_volume+8,-1);
4561
4562 if(zc_read_system_key(KEY_END)) master_volume(digi_volume==255?248:digi_volume-8,-1);
4563 }
4564
4565
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 6510614 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
6510614 if(!get_debug() || !SystemKeys || replay_is_replaying())
4566 6510614 goto bottom;
4567
4568 if(zc_readkey(KEY_D))
4569 {
4570 details = !details;
4571 rectfill(screen,0,0,319,7,BLACK);
4572 rectfill(screen,0,8,31,239,BLACK);
4573 rectfill(screen,288,8,319,239,BLACK);
4574 rectfill(screen,32,232,287,239,BLACK);
4575 }
4576
4577 if(zc_readkey(KEY_P)) Paused=!Paused;
4578
4579 //if(zc_readkey(KEY_P)) centerHero();
4580 if(zc_readkey(KEY_A))
4581 {
4582 Paused=true;
4583 Advance=true;
4584 }
4585
4586 if(zc_readkey(KEY_G)) db=(db==999)?0:999;
4587 #ifndef ALLEGRO_MACOSX
4588 if(zc_readkey(KEY_F8)) Showpal=!Showpal;
4589
4590 if(zc_readkey(KEY_F7))
4591 {
4592 Matrix(ss_speed, ss_density, 0);
4593 game_pal();
4594 }
4595 #else
4596 // The reason these are different on Mac in the first place is that
4597 // the OS doesn't let us use F9 and F10...
4598 if(zc_readkey(KEY_F10)) Showpal=!Showpal;
4599
4600 if(zc_readkey(KEY_F9))
4601 {
4602 Matrix(ss_speed, ss_density, 0);
4603 game_pal();
4604 }
4605 #endif
4606 if(zc_readkey(KEY_PLUS_PAD) || zc_readkey(KEY_EQUALS))
4607 {
4608 //change containers
4609 if(zc_getkey(KEY_ZC_LCONTROL) || zc_getkey(KEY_ZC_RCONTROL))
4610 {
4611 //magic containers
4612 if(zc_getkey(KEY_LSHIFT) || zc_getkey(KEY_RSHIFT))
4613 {
4614 game->set_maxmagic(zc_min(game->get_maxmagic()+game->get_mp_per_block(),game->get_mp_per_block()*8));
4615 }
4616 else
4617 {
4618 game->set_maxlife(zc_min(game->get_maxlife()+game->get_hp_per_heart(),game->get_hp_per_heart()*24));
4619 }
4620 }
4621 else
4622 {
4623 if(zc_getkey(KEY_LSHIFT) || zc_getkey(KEY_RSHIFT))
4624 {
4625 game->set_magic(zc_min(game->get_magic()+1,game->get_maxmagic()));
4626 }
4627 else
4628 {
4629 game->set_life(zc_min(game->get_life()+1,game->get_maxlife()));
4630 }
4631 }
4632 }
4633
4634 if(zc_readkey(KEY_MINUS_PAD) || zc_readkey(KEY_MINUS))
4635 {
4636 //change containers
4637 if(zc_getkey(KEY_ZC_LCONTROL) || zc_getkey(KEY_ZC_RCONTROL))
4638 {
4639 //magic containers
4640 if(zc_getkey(KEY_LSHIFT) || zc_getkey(KEY_RSHIFT))
4641 {
4642 game->set_maxmagic(zc_max(game->get_maxmagic()-game->get_mp_per_block(),0));
4643 game->set_magic(zc_min(game->get_maxmagic(), game->get_magic()));
4644 //heart containers
4645 }
4646 else
4647 {
4648 game->set_maxlife(zc_max(game->get_maxlife()-game->get_hp_per_heart(),game->get_hp_per_heart()));
4649 game->set_life(zc_min(game->get_maxlife(), game->get_life()));
4650 }
4651 }
4652 else
4653 {
4654 if(zc_getkey(KEY_LSHIFT) || zc_getkey(KEY_RSHIFT))
4655 {
4656 game->set_magic(zc_max(game->get_magic()-1,0));
4657 }
4658 else
4659 {
4660 game->set_life(zc_max(game->get_life()-1,0));
4661 }
4662 }
4663 }
4664
4665 if(zc_readkey(KEY_COMMA)) jukebox(currmidi-1);
4666
4667 if(zc_readkey(KEY_STOP)) jukebox(currmidi+1);
4668
4669 verifyBothWeapons();
4670
4671 bottom:
4672
4673
1/2
✓ Branch 0 taken 6510614 times.
✗ Branch 1 not taken.
6510614 if(input_idle(true) > after_time())
4674 {
4675 Matrix(ss_speed, ss_density, 0);
4676 game_pal();
4677 }
4678 6510614 }
4679
4680 330136 void checkQuitKeys()
4681 {
4682 #ifndef ALLEGRO_MACOSX
4683
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 330136 times.
330136 if(key[KEY_F9]) f_Quit(qRESET);
4684
4685
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 330136 times.
330136 if(key[KEY_F10]) f_Quit(qEXIT);
4686 #else
4687 if(key[KEY_F7]) f_Quit(qRESET);
4688
4689 if(key[KEY_F8]) f_Quit(qEXIT);
4690 #endif
4691 330136 }
4692
4693 6510614 bool CheatModifierKeys()
4694 {
4695 // Cheats are replayed via the X cheat step, no need to check for keyboard input
4696 // to trigger cheats.
4697
1/2
✓ Branch 0 taken 6510614 times.
✗ Branch 1 not taken.
6510614 if (replay_is_replaying())
4698 6510614 return false;
4699
4700 if ( ( cheat_modifier_keys[0] > 0 && key[cheat_modifier_keys[0]] ) ||
4701 ( cheat_modifier_keys[1] > 0 && key[cheat_modifier_keys[1]] ) ||
4702 (cheat_modifier_keys[0] <= 0 && cheat_modifier_keys[1] <= 0))
4703 {
4704 if ( ( cheat_modifier_keys[2] <= 0 || key[cheat_modifier_keys[2]] ) ||
4705 ( cheat_modifier_keys[3] > 0 && key[cheat_modifier_keys[3]] ) ||
4706 (cheat_modifier_keys[2] <= 0 && cheat_modifier_keys[3] <= 0))
4707 {
4708 return true;
4709 }
4710 }
4711 return false;
4712 6510614 }
4713
4714 //99:05:54, for some reason?
4715 #define OLDMAXTIME 21405240
4716 //9000:00:00, the highest even-thousand hour fitting within 32b signed. This is 375 *DAYS*.
4717 #define MAXTIME 1944000000
4718
4719 6510665 void advanceframe(bool allowwavy, bool sfxcleanup, bool allowF6Script)
4720 {
4721
2/2
✓ Branch 0 taken 6242564 times.
✓ Branch 1 taken 268101 times.
6510665 if(zcmusic!=NULL)
4722 {
4723 268101 zcmusic_poll();
4724 268101 }
4725
4726 6510665 updatescr(allowwavy);
4727
4728
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 6510665 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 6510665 times.
6510665 while(Paused && !Advance && !Quit)
4729 {
4730 // have to call this, otherwise we'll get an infinite loop
4731 syskeys();
4732 if(allowF6Script)
4733 {
4734 FFCore.runF6Engine();
4735 }
4736 throttleFPS();
4737
4738 #ifdef _WIN32
4739
4740 if(use_dwm_flush)
4741 {
4742 do_DwmFlush();
4743 }
4744
4745 #endif
4746
4747 // to keep music playing
4748 if(zcmusic!=NULL)
4749 {
4750 zcmusic_poll();
4751 }
4752
4753 update_hw_screen();
4754 }
4755
4756
2/2
✓ Branch 0 taken 6510624 times.
✓ Branch 1 taken 41 times.
6510665 if(Quit)
4757 41 return;
4758
4759
3/4
✓ Branch 0 taken 6428635 times.
✓ Branch 1 taken 81989 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6428635 times.
6510624 if(Playing && game->get_time()<unsigned(get_bit(quest_rules,qr_GREATER_MAX_TIME) ? MAXTIME : OLDMAXTIME))
4760 6428635 game->change_time(1);
4761
4762 6510624 Advance=false;
4763
4764
2/4
✓ Branch 0 taken 6510624 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6510624 times.
6510624 if (!replay_is_active() || replay_get_version() >= 11)
4765 for (int i = 0; i < ZC_CONTROL_STATES; i++)
4766 down_control_states[i] = raw_control_state[i];
4767
4768
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 6510622 times.
6510624 if (replay_is_active())
4769 {
4770
2/2
✓ Branch 0 taken 1270461 times.
✓ Branch 1 taken 5240161 times.
6510622 if (replay_get_version() >= 3)
4771 5240161 replay_poll();
4772
4773
5/6
✓ Branch 0 taken 6510614 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3089962 times.
✓ Branch 3 taken 3420652 times.
✓ Branch 4 taken 100535 times.
✓ Branch 5 taken 2989427 times.
6510622 if (replay_get_version() >= 11 || (replay_get_version() >= 6 && replay_get_version() < 8))
4774 100535 replay_peek_input();
4775 6510614 }
4776
4777 6510624 load_control_called_this_frame = false;
4778
4779 6510624 poll_keyboard();
4780 6510624 update_keys();
4781
4782 6510624 ++frame;
4783
4784
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 6510614 times.
6510624 if (replay_is_replaying())
4785 6510614 replay_do_cheats();
4786 6510624 syskeys();
4787
4788 // The mouse variables can change from the mouse thread at anytime during a frame,
4789 // so save the result at the start so that replaying is consistent.
4790 6510624 script_mouse_x = gui_mouse_x();
4791 6510624 script_mouse_y = gui_mouse_y();
4792 6510624 script_mouse_z = mouse_z;
4793 6510624 script_mouse_b = mouse_b;
4794
4795 // Cheats used via the System menu (called by syskeys) will call cheats_enqueue. syskeys
4796 // is called just above, and in the paused loop above, so the queue-and-defer-slightly
4797 // approach here means it doesn't matter which call adds the cheat.
4798 6510624 cheats_execute_queued();
4799
4800
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 6510614 times.
6510624 if (replay_is_replaying())
4801 6510614 replay_peek_quit();
4802
2/2
✓ Branch 0 taken 6510610 times.
✓ Branch 1 taken 14 times.
6510624 if (GameFlags & GAMEFLAG_TRYQUIT)
4803 14 replay_step_quit(0);
4804
2/2
✓ Branch 0 taken 1835 times.
✓ Branch 1 taken 6508789 times.
6510624 if(allowF6Script)
4805 {
4806 6508789 FFCore.runF6Engine();
4807 6508789 }
4808
2/2
✓ Branch 0 taken 6510449 times.
✓ Branch 1 taken 175 times.
6510624 if (Quit)
4809 175 replay_step_quit(Quit);
4810 // Someday... maybe install a Turbo button here?
4811 6510624 throttleFPS();
4812
4813 #ifdef _WIN32
4814
4815 if(use_dwm_flush)
4816 {
4817 do_DwmFlush();
4818 }
4819
4820 #endif
4821
4822 //textprintf_ex(screen,font,0,72,254,BLACK,"%d %d", lastentrance, lastentrance_dmap);
4823
2/2
✓ Branch 0 taken 29901 times.
✓ Branch 1 taken 6480723 times.
6510624 if(sfxcleanup)
4824 6480723 sfx_cleanup();
4825 6510665 }
4826
4827 59 void zapout()
4828 {
4829 59 set_clip_rect(scrollbuf, 0, 0, scrollbuf->w, scrollbuf->h);
4830 59 blit(framebuf,scrollbuf,0,0,256,0,256,224);
4831
4832 59 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
4833 59 script_drawing_commands.Clear();
4834
4835 // zap out
4836
2/2
✓ Branch 0 taken 59 times.
✓ Branch 1 taken 1416 times.
1475 for(int32_t i=1; i<=24; i++)
4837 {
4838 1416 draw_fuzzy(i);
4839 1416 advanceframe(true);
4840
4841
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1416 times.
1416 if(Quit)
4842 {
4843 break;
4844 }
4845 1416 }
4846 59 }
4847
4848 59 void zapin()
4849 {
4850 59 FFCore.warpScriptCheck();
4851 59 draw_screen(tmpscr);
4852 59 set_clip_rect(scrollbuf, 0, 0, scrollbuf->w, scrollbuf->h);
4853 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
4854 59 blit(framebuf,scrollbuf,0,0,256,0,256,224);
4855
4856 // zap out
4857 59 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
4858
2/2
✓ Branch 0 taken 59 times.
✓ Branch 1 taken 1416 times.
1475 for(int32_t i=24; i>=1; i--)
4859 {
4860 1416 draw_fuzzy(i);
4861 1416 advanceframe(true);
4862
4863
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1416 times.
1416 if(Quit)
4864 {
4865 break;
4866 }
4867 1416 }
4868 59 }
4869
4870
4871 23 void wavyout(bool showhero)
4872 {
4873 23 draw_screen(tmpscr, showhero);
4874 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
4875
4876 23 BITMAP *wavebuf = create_bitmap_ex(8,288,224);
4877 23 clear_to_color(wavebuf,0);
4878 23 blit(framebuf,wavebuf,0,0,16,0,256,224);
4879
4880 static PALETTE wavepal;
4881
4882 int32_t ofs;
4883 23 int32_t amplitude=8;
4884
4885 23 int32_t wavelength=4;
4886 23 double palpos=0, palstep=4, palstop=126;
4887
4888 23 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
4889
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 966 times.
989 for(int32_t i=0; i<168; i+=wavelength)
4890 {
4891
2/2
✓ Branch 0 taken 247296 times.
✓ Branch 1 taken 966 times.
248262 for(int32_t l=0; l<256; l++)
4892 {
4893 247296 wavepal[l].r=vbound(int32_t(RAMpal[l].r+((palpos/palstop)*(63-RAMpal[l].r))),0,63);
4894 247296 wavepal[l].g=vbound(int32_t(RAMpal[l].g+((palpos/palstop)*(63-RAMpal[l].g))),0,63);
4895 247296 wavepal[l].b=vbound(int32_t(RAMpal[l].b+((palpos/palstop)*(63-RAMpal[l].b))),0,63);
4896 247296 }
4897
4898 966 palpos+=palstep;
4899
4900
1/2
✓ Branch 0 taken 966 times.
✗ Branch 1 not taken.
966 if(palpos>=0)
4901 {
4902 966 hw_palette = &wavepal;
4903 966 update_hw_pal = true;
4904 966 }
4905 else
4906 {
4907 hw_palette = &RAMpal;
4908 update_hw_pal = true;
4909 }
4910
4911
2/2
✓ Branch 0 taken 162288 times.
✓ Branch 1 taken 966 times.
163254 for(int32_t j=0; j+playing_field_offset<224; j++)
4912 {
4913
2/2
✓ Branch 0 taken 41545728 times.
✓ Branch 1 taken 162288 times.
41708016 for(int32_t k=0; k<256; k++)
4914 {
4915 41545728 ofs=0;
4916
4917
4/4
✓ Branch 0 taken 20278272 times.
✓ Branch 1 taken 21267456 times.
✓ Branch 2 taken 10139136 times.
✓ Branch 3 taken 10139136 times.
41545728 if((j<i)&&(j&1))
4918 {
4919 10139136 ofs=int32_t(zc::math::Sin((double(i+j)*2*PI/168.0))*amplitude);
4920 10139136 }
4921
4922 41545728 framebuf->line[j+playing_field_offset][k]=wavebuf->line[j+playing_field_offset][k+ofs+16];
4923 41545728 }
4924 162288 }
4925
4926 966 advanceframe(true);
4927
4928 // animate_combos();
4929
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 966 times.
966 if(Quit)
4930 break;
4931 966 }
4932
4933 23 destroy_bitmap(wavebuf);
4934 23 }
4935
4936 23 void wavyin()
4937 {
4938 23 draw_screen(tmpscr);
4939 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
4940
4941 23 BITMAP *wavebuf = create_bitmap_ex(8,288,224);
4942 23 clear_to_color(wavebuf,0);
4943 23 blit(framebuf,wavebuf,0,0,16,0,256,224);
4944
4945 static PALETTE wavepal;
4946
4947 //Breaks dark rooms.
4948 //In any case I don't think we need this, since palette is already loaded in doWarp() (famous last words...) -DD
4949 /*
4950 loadfullpal();
4951 loadlvlpal(DMaps[currdmap].color);
4952 ringcolor(false);
4953 */
4954 23 refreshpal=false;
4955 int32_t ofs;
4956 23 int32_t amplitude=8;
4957 23 int32_t wavelength=4;
4958 23 double palpos=168, palstep=4, palstop=126;
4959
4960 23 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
4961
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 966 times.
989 for(int32_t i=0; i<168; i+=wavelength)
4962 {
4963
2/2
✓ Branch 0 taken 247296 times.
✓ Branch 1 taken 966 times.
248262 for(int32_t l=0; l<256; l++)
4964 {
4965 247296 wavepal[l].r=vbound(int32_t(RAMpal[l].r+((palpos/palstop)*(63-RAMpal[l].r))),0,63);
4966 247296 wavepal[l].g=vbound(int32_t(RAMpal[l].g+((palpos/palstop)*(63-RAMpal[l].g))),0,63);
4967 247296 wavepal[l].b=vbound(int32_t(RAMpal[l].b+((palpos/palstop)*(63-RAMpal[l].b))),0,63);
4968 247296 }
4969
4970 966 palpos-=palstep;
4971
4972
1/2
✓ Branch 0 taken 966 times.
✗ Branch 1 not taken.
966 if(palpos>=0)
4973 {
4974 966 hw_palette = &wavepal;
4975 966 update_hw_pal = true;
4976 966 }
4977 else
4978 {
4979 hw_palette = &RAMpal;
4980 update_hw_pal = true;
4981 }
4982
4983
2/2
✓ Branch 0 taken 162288 times.
✓ Branch 1 taken 966 times.
163254 for(int32_t j=0; j+playing_field_offset<224; j++)
4984 {
4985
2/2
✓ Branch 0 taken 41545728 times.
✓ Branch 1 taken 162288 times.
41708016 for(int32_t k=0; k<256; k++)
4986 {
4987 41545728 ofs=0;
4988
4989
4/4
✓ Branch 0 taken 21020160 times.
✓ Branch 1 taken 20525568 times.
✓ Branch 2 taken 10633728 times.
✓ Branch 3 taken 10386432 times.
41545728 if((j<(167-i))&&(j&1))
4990 {
4991 10386432 ofs=int32_t(zc::math::Sin((double(i+j)*2*PI/168.0))*amplitude);
4992 10386432 }
4993
4994 41545728 framebuf->line[j+playing_field_offset][k]=wavebuf->line[j+playing_field_offset][k+ofs+16];
4995 41545728 }
4996 162288 }
4997
4998 966 advanceframe(true);
4999 // animate_combos();
5000
5001
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 966 times.
966 if(Quit)
5002 break;
5003 966 }
5004
5005 23 destroy_bitmap(wavebuf);
5006 23 }
5007
5008 1619 void blackscr(int32_t fcnt,bool showsubscr)
5009 {
5010 1619 reset_pal_cycling();
5011 1619 script_drawing_commands.Clear();
5012
5013 1619 FFCore.warpScriptCheck();
5014 1619 bool showtime = game->should_show_time();
5015
2/2
✓ Branch 0 taken 1619 times.
✓ Branch 1 taken 48500 times.
50119 while(fcnt>0)
5016 {
5017 48500 clear_bitmap(framebuf);
5018
5019
2/2
✓ Branch 0 taken 13500 times.
✓ Branch 1 taken 35000 times.
48500 if(showsubscr)
5020 {
5021 35000 put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,showtime,sspUP);
5022
3/4
✓ Branch 0 taken 35000 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 750 times.
✓ Branch 3 taken 34250 times.
35000 if(get_bit(quest_rules, qr_SCRIPTDRAWSINWARPS) || (get_bit(quest_rules, qr_PASSIVE_SUBSCRIPT_RUNS_WHEN_GAME_IS_FROZEN)))
5023 {
5024 750 do_script_draws(framebuf, tmpscr, 0, playing_field_offset);
5025 750 }
5026 35000 }
5027
5028 48500 advanceframe(true);
5029
5030
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48500 times.
48500 if(Quit)
5031 break;
5032
5033 48500 --fcnt;
5034 }
5035 1619 }
5036
5037 563 void openscreen(int32_t shape)
5038 {
5039 563 reset_pal_cycling();
5040 563 black_opening_count=0;
5041
5042
3/4
✓ Branch 0 taken 98 times.
✓ Branch 1 taken 465 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 98 times.
563 if(COOLSCROLL || shape>-1)
5043 {
5044 465 open_black_opening(HeroX()+8, (HeroY()-HeroZ()-HeroFakeZ())+8+playing_field_offset, true, shape);
5045 465 return;
5046 }
5047 else
5048 {
5049 98 Hero.setDontDraw(true);
5050 98 show_subscreen_dmap_dots=false;
5051 98 show_subscreen_numbers=false;
5052 // show_subscreen_items=false;
5053 98 show_subscreen_life=false;
5054 }
5055
5056 98 int32_t x=128;
5057
5058 98 FFCore.warpScriptCheck();
5059
2/2
✓ Branch 0 taken 98 times.
✓ Branch 1 taken 7840 times.
7938 for(int32_t i=0; i<80; i++)
5060 {
5061 7840 draw_screen(tmpscr);
5062 //? draw_screen already draws the subscreen -DD
5063 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
5064 7840 x=128-(((i*128/80)/8)*8);
5065
5066
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7840 times.
7840 if(x>0)
5067 {
5068 7840 rectfill(framebuf,0,playing_field_offset,x,167+playing_field_offset,0);
5069 7840 rectfill(framebuf,256-x,playing_field_offset,255,167+playing_field_offset,0);
5070 7840 }
5071
5072 7840 advanceframe(true);
5073
5074
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7840 times.
7840 if(Quit)
5075 {
5076 break;
5077 }
5078 7840 }
5079
5080 98 Hero.setDontDraw(false);
5081 98 show_subscreen_items=true;
5082 98 show_subscreen_dmap_dots=true;
5083 563 }
5084
5085 void closescreen(int32_t shape)
5086 {
5087 reset_pal_cycling();
5088 black_opening_count=0;
5089
5090 if(COOLSCROLL || shape>-1)
5091 {
5092 close_black_opening(HeroX()+8, (HeroY()-HeroZ()-HeroFakeZ())+8+playing_field_offset, true, shape);
5093 return;
5094 }
5095 else
5096 {
5097 Hero.setDontDraw(true);
5098 show_subscreen_dmap_dots=false;
5099 show_subscreen_numbers=false;
5100 // show_subscreen_items=false;
5101 show_subscreen_life=false;
5102 }
5103
5104 int32_t x=128;
5105
5106 FFCore.warpScriptCheck();
5107 for(int32_t i=79; i>=0; --i)
5108 {
5109 draw_screen(tmpscr);
5110 //? draw_screen already draws the subscreen -DD
5111 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
5112 x=128-(((i*128/80)/8)*8);
5113
5114 if(x>0)
5115 {
5116 rectfill(framebuf,0,playing_field_offset,x,167+playing_field_offset,0);
5117 rectfill(framebuf,256-x,playing_field_offset,255,167+playing_field_offset,0);
5118 }
5119
5120 advanceframe(true);
5121
5122 if(Quit)
5123 {
5124 break;
5125 }
5126 }
5127
5128 Hero.setDontDraw(false);
5129 show_subscreen_items=true;
5130 show_subscreen_dmap_dots=true;
5131 }
5132
5133 122 int32_t TriforceCount()
5134 {
5135 122 int32_t c=0;
5136
5137
2/2
✓ Branch 0 taken 976 times.
✓ Branch 1 taken 122 times.
1098 for(int32_t i=1; i<=8; i++)
5138
2/2
✓ Branch 0 taken 326 times.
✓ Branch 1 taken 650 times.
1626 if(game->lvlitems[i]&liTRIFORCE)
5139 650 ++c;
5140
5141 122 return c;
5142 }
5143
5144 int32_t onCustomGame()
5145 {
5146 int32_t file = getsaveslot();
5147
5148 if(file < 0)
5149 return D_O_K;
5150
5151 bool ret = (custom_game(file)!=0);
5152 return ret ? D_CLOSE : D_O_K;
5153 }
5154
5155 int32_t onContinue()
5156 {
5157 return D_CLOSE;
5158 }
5159
5160 int32_t onEsc() // Unused?? -L
5161 {
5162 return zc_getrawkey(KEY_ESC, true)?D_CLOSE:D_O_K;
5163 }
5164
5165 int32_t onVsync()
5166 {
5167 Throttlefps = !Throttlefps;
5168 zc_set_config(cfg_sect,"throttlefps", (int32_t)Throttlefps);
5169 return D_O_K;
5170 }
5171
5172 int32_t onWinPosSave()
5173 {
5174 SaveWinPos = !SaveWinPos;
5175 zc_set_config(cfg_sect,"save_window_position",(int32_t)SaveWinPos);
5176 return D_O_K;
5177 }
5178
5179 int32_t onClickToFreeze()
5180 {
5181 ClickToFreeze = !ClickToFreeze;
5182 zc_set_config(cfg_sect,"clicktofreeze", (int32_t)ClickToFreeze);
5183 return D_O_K;
5184 }
5185
5186 int32_t OnSaveZCConfig()
5187 {
5188 if(jwin_alert3(
5189 "Save Configuration",
5190 "Are you sure that you wish to save your present configuration settings?",
5191 "This will overwrite your prior settings!",
5192 NULL,
5193 "&Yes",
5194 "&No",
5195 NULL,
5196 'y',
5197 'n',
5198 0,
5199 lfont) == 1)
5200 {
5201 save_game_configs();
5202 return D_O_K;
5203 }
5204 else return D_O_K;
5205 }
5206
5207 int32_t OnnClearQuestDir()
5208 {
5209 if(jwin_alert3(
5210 "Clear Current Directory Cache",
5211 "Are you sure that you wish to clear the current cached directory?",
5212 "This will default the current directory to the ROOT for this instance of ZC Player!",
5213 NULL,
5214 "&Yes",
5215 "&No",
5216 NULL,
5217 'y',
5218 'n',
5219 0,
5220 lfont) == 1)
5221 {
5222 zc_set_config("zeldadx","win_qst_dir","");
5223 flush_config_file();
5224 strcpy(qstdir,"");
5225 #ifdef __EMSCRIPTEN__
5226 em_sync_fs();
5227 #endif
5228 return D_O_K;
5229 }
5230 else return D_O_K;
5231 }
5232
5233
5234 int32_t onConsoleZASM()
5235 {
5236 if ( !zasm_debugger )
5237 {
5238 AlertDialog("WARNING: ZASM Debugger",
5239 "Enabling this will open the ZASM Debugger Console"
5240 "\nThis will likely grind ZC to a halt with lag."
5241 "\nTo make any use of this, it is suggested that you read"
5242 "\nthe documentation for 'void Breakpoint(char[] string);'"
5243 " in 'ZScript_Additions.txt'"
5244 "\nThis is not recommended for normal users,"
5245 " and is only intended for ZC developers,"
5246 "\nor quest developers coding directly in ZASM"
5247 "\nAre you sure that you wish to open the ZASM Debugger?",
5248 [&](bool ret,bool)
5249 {
5250 if(ret)
5251 {
5252 FFCore.ZASMPrint(true);
5253 }
5254 }).show();
5255 return D_O_K;
5256 }
5257 else
5258 {
5259 FFCore.ZASMPrint(false);
5260 return D_O_K;
5261 }
5262 }
5263
5264
5265 int32_t onConsoleZScript()
5266 {
5267 if ( !zscript_debugger )
5268 {
5269 AlertDialog("ZScript Debugger",
5270 "Enabling this will open the ZScript Debugger Console"
5271 "\nThis will display any messages logged by scripts,"
5272 " including script errors."
5273 "\nAre you sure that you wish to open the ZScript Debugger?",
5274 [&](bool ret,bool)
5275 {
5276 if(ret)
5277 {
5278 FFCore.ZScriptConsole(true);
5279 }
5280 }).show();
5281 return D_O_K;
5282 }
5283 else
5284 {
5285 FFCore.ZScriptConsole(false);
5286 return D_O_K;
5287 }
5288 }
5289
5290 int32_t onClrConsoleOnLoad()
5291 {
5292 clearConsoleOnLoad = !clearConsoleOnLoad;
5293 zc_set_config("CONSOLE","clear_console_on_load",clearConsoleOnLoad?1:0);
5294 return D_O_K;
5295 }
5296
5297
5298 int32_t onFrameSkip()
5299 {
5300 FrameSkip = !FrameSkip;
5301 return D_O_K;
5302 }
5303
5304 int32_t onSaveDragResize()
5305 {
5306 SaveDragResize = !SaveDragResize;
5307 zc_set_config(cfg_sect,"save_drag_resize",(int32_t)SaveDragResize);
5308 return D_O_K;
5309 }
5310
5311 int32_t onDragAspect()
5312 {
5313 DragAspect = !DragAspect;
5314 zc_set_config(cfg_sect,"drag_aspect",(int32_t)DragAspect);
5315 return D_O_K;
5316 }
5317
5318 int32_t onTransLayers()
5319 {
5320 TransLayers = !TransLayers;
5321 zc_set_config(cfg_sect,"translayers",(int32_t)TransLayers);
5322 return D_O_K;
5323 }
5324
5325 int32_t onNESquit()
5326 {
5327 NESquit = !NESquit;
5328 zc_set_config(cfg_sect,"fastquit",(int32_t)NESquit);
5329 return D_O_K;
5330 }
5331
5332 int32_t onVolKeys()
5333 {
5334 volkeys = !volkeys;
5335 zc_set_config(sfx_sect,"volkeys",(int32_t)volkeys);
5336 return D_O_K;
5337 }
5338
5339 int32_t onShowFPS()
5340 {
5341 ShowFPS = !ShowFPS;
5342 zc_set_config(cfg_sect,"showfps",(int32_t)ShowFPS);
5343 return D_O_K;
5344 }
5345
5346 768252452 bool is_Fkey(int32_t k)
5347 {
5348
2/2
✓ Branch 0 taken 78127368 times.
✓ Branch 1 taken 690125084 times.
768252452 switch(k)
5349 {
5350 case KEY_F1:
5351 case KEY_F2:
5352 case KEY_F3:
5353 case KEY_F4:
5354 case KEY_F5:
5355 case KEY_F6:
5356 case KEY_F7:
5357 case KEY_F8:
5358 case KEY_F9:
5359 case KEY_F10:
5360 case KEY_F11:
5361 case KEY_F12:
5362 78127368 return true;
5363 }
5364
5365 690125084 return false;
5366 768252452 }
5367
5368 void kb_getkey(DIALOG *d);
5369
5370 //Used by all keyboard key settings dialogues.
5371 void kb_clearjoystick(DIALOG *d)
5372 {
5373 d->flags|=D_SELECTED;
5374
5375 scare_mouse();
5376 jwin_button_proc(MSG_DRAW,d,0);
5377 jwin_draw_win(gui_bmp, (gui_bmp->w-160)/2, (gui_bmp->h-48)/2, 168, 48, FR_WIN);
5378 // text_mode(vc(11));
5379 textout_centre_ex(gui_bmp, font, "Press any key to clear", gui_bmp->w/2, gui_bmp->h/2 - 8, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5380 textout_centre_ex(gui_bmp, font, "ESC to cancel", gui_bmp->w/2, gui_bmp->h/2, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5381 unscare_mouse();
5382
5383 update_hw_screen(true);
5384
5385 clear_keybuf();
5386 int32_t k = next_press_key();
5387 clear_keybuf();
5388
5389 //shnarf
5390 //47=f1
5391 //59=esc
5392 // if(k>0 && k<123 && !((k>46)&&(k<60)))
5393 // *((int32_t*)d->dp3) = k;
5394 if ( k != 59 ) *((int32_t*)d->dp3) = 0;
5395
5396
5397 d->flags&=~D_SELECTED;
5398 }
5399
5400 //Clears key to 0.
5401 //Used by all keyboard key settings dialogues.
5402 void kb_clearkey(DIALOG *d);
5403
5404 int32_t d_j_clearbutton_proc(int32_t msg,DIALOG *d,int32_t c)
5405 {
5406 switch(msg)
5407 {
5408 case MSG_KEY:
5409 case MSG_CLICK:
5410
5411 kb_clearjoystick(d);
5412
5413 while(gui_mouse_b())
5414 {
5415 clear_keybuf();
5416 rest(1);
5417 }
5418
5419 return D_REDRAW;
5420 }
5421
5422 return jwin_button_proc(msg,d,c);
5423 }
5424
5425 int32_t d_kbutton_proc(int32_t msg,DIALOG *d,int32_t c);
5426 //Only used in keyboard settings dialogues to clear keys.
5427 int32_t d_k_clearbutton_proc(int32_t msg,DIALOG *d,int32_t c);
5428
5429 void j_getbtn(DIALOG *d)
5430 {
5431 d->flags|=D_SELECTED;
5432 scare_mouse();
5433 jwin_button_proc(MSG_DRAW,d,0);
5434 jwin_draw_win(gui_bmp, (gui_bmp->w-160)/2, (gui_bmp->h-48)/2, 160, 48, FR_WIN);
5435 // text_mode(vc(11));
5436 int32_t y = gui_bmp->h/2 - 12;
5437 textout_centre_ex(gui_bmp, font, "Press a button", gui_bmp->w/2, y, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5438 textout_centre_ex(gui_bmp, font, "ESC to cancel", gui_bmp->w/2, y+8, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5439 textout_centre_ex(gui_bmp, font, "SPACE to disable", gui_bmp->w/2, y+16, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5440 unscare_mouse();
5441
5442 update_hw_screen(true);
5443
5444 int32_t b = next_press_btn();
5445
5446 if(b>=0)
5447 *((int32_t*)d->dp3) = b;
5448
5449 d->flags&=~D_SELECTED;
5450
5451 if (player)
5452 player->joy_on = TRUE;
5453 }
5454
5455 int32_t d_jbutton_proc(int32_t msg,DIALOG *d,int32_t c)
5456 {
5457 switch(msg)
5458 {
5459 case MSG_KEY:
5460 case MSG_CLICK:
5461
5462 j_getbtn(d);
5463
5464 while(gui_mouse_b()) {
5465 rest(1);
5466 clear_keybuf();
5467 }
5468
5469 return D_REDRAW;
5470 }
5471
5472 return jwin_button_proc(msg,d,c);
5473 }
5474
5475 //shnarf
5476 extern const char *key_str[];
5477 std::string get_keystr(int key);
5478
5479 const char *pan_str[4] = { "MONO", " 1/2", " 3/4", "FULL" };
5480 //extern int32_t zcmusic_bufsz;
5481
5482 static char str_a[80],str_b[80],str_s[80],str_m[80],str_l[80],str_r[80],str_p[80],str_ex1[80],str_ex2[80],str_ex3[80],str_ex4[80],
5483 str_leftmod1[80],str_leftmod2[80],str_rightmod1[80],str_rightmod2[80], str_left[80], str_right[80], str_up[80], str_down[80];
5484
5485 int32_t d_stringloader(int32_t msg,DIALOG *d,int32_t c)
5486 {
5487 //these are here to bypass compiler warnings about unused arguments
5488 c=c;
5489
5490 if(msg==MSG_DRAW)
5491 {
5492 switch(d->w)
5493 {
5494 case 0:
5495 sprintf(str_a,"%03d\n%s",Akey,key_str[Akey]);
5496 sprintf(str_b,"%03d\n%s",Bkey,key_str[Bkey]);
5497 sprintf(str_s,"%03d\n%s",Skey,key_str[Skey]);
5498 sprintf(str_l,"%03d\n%s",Lkey,key_str[Lkey]);
5499 sprintf(str_r,"%03d\n%s",Rkey,key_str[Rkey]);
5500 sprintf(str_p,"%03d\n%s",Pkey,key_str[Pkey]);
5501 sprintf(str_ex1,"%03d\n%s",Exkey1,key_str[Exkey1]);
5502 sprintf(str_ex2,"%03d\n%s",Exkey2,key_str[Exkey2]);
5503 sprintf(str_ex3,"%03d\n%s",Exkey3,key_str[Exkey3]);
5504 sprintf(str_ex4,"%03d\n%s",Exkey4,key_str[Exkey4]);
5505 sprintf(str_up,"%03d\n%s",DUkey,key_str[DUkey]);
5506 sprintf(str_down,"%03d\n%s",DDkey,key_str[DDkey]);
5507 sprintf(str_left,"%03d\n%s",DLkey,key_str[DLkey]);
5508 sprintf(str_right,"%03d\n%s",DRkey,key_str[DRkey]);
5509 sprintf(str_leftmod1,"%03d\n%s",cheat_modifier_keys[0],key_str[cheat_modifier_keys[0]]);
5510 sprintf(str_leftmod2,"%03d\n%s",cheat_modifier_keys[1],key_str[cheat_modifier_keys[1]]);
5511 sprintf(str_rightmod1,"%03d\n%s",cheat_modifier_keys[2],key_str[cheat_modifier_keys[2]]);
5512 sprintf(str_rightmod2,"%03d\n%s",cheat_modifier_keys[3],key_str[cheat_modifier_keys[3]]);
5513 break;
5514
5515 case 1:
5516 sprintf(str_a,"%03d\n%s",Abtn,joybtn_name(Abtn));
5517 sprintf(str_b,"%03d\n%s",Bbtn,joybtn_name(Bbtn));
5518 sprintf(str_s,"%03d\n%s",Sbtn,joybtn_name(Sbtn));
5519 sprintf(str_l,"%03d\n%s",Lbtn,joybtn_name(Lbtn));
5520 sprintf(str_r,"%03d\n%s",Rbtn,joybtn_name(Rbtn));
5521 sprintf(str_m,"%03d\n%s",Mbtn,joybtn_name(Mbtn));
5522 sprintf(str_p,"%03d\n%s",Pbtn,joybtn_name(Pbtn));
5523 sprintf(str_ex1,"%03d\n%s",Exbtn1,joybtn_name(Exbtn1));
5524 sprintf(str_ex2,"%03d\n%s",Exbtn2,joybtn_name(Exbtn2));
5525 sprintf(str_ex3,"%03d\n%s",Exbtn3,joybtn_name(Exbtn3));
5526 sprintf(str_ex4,"%03d\n%s",Exbtn4,joybtn_name(Exbtn4));
5527 sprintf(str_up,"%03d\n%s",DUbtn,joybtn_name(DUbtn));
5528 sprintf(str_down,"%03d\n%s",DDbtn,joybtn_name(DDbtn));
5529 sprintf(str_left,"%03d\n%s",DLbtn,joybtn_name(DLbtn));
5530 sprintf(str_right,"%03d\n%s",DRbtn,joybtn_name(DRbtn));
5531 sprintf(str_leftmod1,"%03d\n%s",cheat_modifier_keys[0],key_str[cheat_modifier_keys[0]]);
5532 sprintf(str_leftmod2,"%03d\n%s",cheat_modifier_keys[1],key_str[cheat_modifier_keys[1]]);
5533 sprintf(str_rightmod1,"%03d\n%s",cheat_modifier_keys[2],key_str[cheat_modifier_keys[2]]);
5534 sprintf(str_rightmod2,"%03d\n%s",cheat_modifier_keys[3],key_str[cheat_modifier_keys[3]]);
5535 break;
5536
5537 case 2:
5538 sprintf(str_a," %3d",midi_volume);
5539 sprintf(str_b," %3d",digi_volume);
5540 sprintf(str_l," %3d",emusic_volume);
5541 sprintf(str_m," %3dKB",zcmusic_bufsz);
5542 sprintf(str_r," %3d",sfx_volume);
5543 strcpy(str_s,pan_str[pan_style]);
5544 sprintf(str_leftmod1,"%3d\n%s",cheat_modifier_keys[0],key_str[cheat_modifier_keys[0]]);
5545 sprintf(str_leftmod2,"%3d\n%s",cheat_modifier_keys[1],key_str[cheat_modifier_keys[1]]);
5546 sprintf(str_rightmod1,"%3d\n%s",cheat_modifier_keys[2],key_str[cheat_modifier_keys[2]]);
5547 sprintf(str_rightmod2,"%3d\n%s",cheat_modifier_keys[3],key_str[cheat_modifier_keys[3]]);
5548 break;
5549 }
5550 }
5551
5552 return D_O_K;
5553 }
5554
5555 int32_t set_vol(void *dp3, int32_t d2)
5556 {
5557 switch(((int32_t*)dp3)[0])
5558 {
5559 case 0:
5560 midi_volume = zc_min(d2<<3,255);
5561 break;
5562
5563 case 1:
5564 digi_volume = zc_min(d2<<3,255);
5565 break;
5566
5567 case 2:
5568 emusic_volume = zc_min(d2<<3,255);
5569 break;
5570
5571 case 3:
5572 sfx_volume = zc_min(d2<<3,255);
5573 break;
5574 }
5575
5576 scare_mouse();
5577 // text_mode(vc(11));
5578 textprintf_right_ex(screen,lfont_l, ((int32_t*)dp3)[1],((int32_t*)dp3)[2],jwin_pal[jcBOXFG],jwin_pal[jcBOX],"%3d",zc_min(d2<<3,255));
5579 unscare_mouse();
5580 return D_O_K;
5581 }
5582
5583 int32_t set_pan(void *dp3, int32_t d2)
5584 {
5585 pan_style = vbound(d2,0,3);
5586 scare_mouse();
5587 // text_mode(vc(11));
5588 textout_right_ex(screen,lfont_l, pan_str[pan_style],((int32_t*)dp3)[1],((int32_t*)dp3)[2],jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5589 unscare_mouse();
5590 return D_O_K;
5591 }
5592
5593 int32_t set_buf(void *dp3, int32_t d2)
5594 {
5595 scare_mouse();
5596 // text_mode(vc(11));
5597 zcmusic_bufsz = d2 + 1;
5598 textprintf_right_ex(screen,lfont_l, ((int32_t*)dp3)[1],((int32_t*)dp3)[2],jwin_pal[jcBOXFG],jwin_pal[jcBOX],"%3dKB",zcmusic_bufsz);
5599 unscare_mouse();
5600 return D_O_K;
5601 }
5602
5603 static int32_t gamepad_btn_list[] =
5604 {
5605 6,
5606 7,8,9,10,11,12,13,14,15,16,17,
5607 18,19,20,21,22,23,24,25,26,27,28,
5608 29,30,31,32,33,34,35,36,37,38,39,
5609 -1
5610 };
5611
5612 static int32_t gamepad_dirs_list[] =
5613 {
5614 40,41,42,43,
5615 44,45,46,47,
5616 48,49,50,51,
5617 52,53,54,55,
5618 56,
5619 -1
5620 };
5621
5622 static TABPANEL gamepad_tabs[] =
5623 {
5624 // (text)
5625 { (char *)"Buttons", D_SELECTED, gamepad_btn_list, 0, NULL },
5626 { (char *)"Directions", 0, gamepad_dirs_list, 0, NULL },
5627 { NULL, 0, NULL, 0, NULL }
5628 };
5629
5630 static DIALOG gamepad_dlg[] =
5631 {
5632 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3)
5633 { jwin_win_proc, 8, 24, 304, 256, 0, 0, 0, D_EXIT, 0, 0, (void *) "Gamepad Controls", NULL, NULL },
5634 { jwin_tab_proc, 8+4, 24+23,304-8,256-52,vc(0), vc(15), 0, 0, 0, 0, (void *) gamepad_tabs, NULL, (void *)gamepad_dlg },
5635 { d_stringloader, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5636 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5637 { jwin_button_proc, 90, 254, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
5638 { jwin_button_proc, 170, 254, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
5639 // 6
5640 { d_dummy_proc, 14, 61, 294, 192, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5641 // 7
5642 { jwin_ctext_proc, 92, 92-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_a, NULL, NULL },
5643 { jwin_ctext_proc, 92, 120-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_b, NULL, NULL },
5644 { jwin_ctext_proc, 92, 148-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_s, NULL, NULL },
5645 { jwin_ctext_proc, 92, 180-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex1, NULL, NULL },
5646 { jwin_ctext_proc, 92, 212-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex3, NULL, NULL },
5647 { jwin_ctext_proc, 237, 92-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_l, NULL, NULL },
5648 { jwin_ctext_proc, 237, 120-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_r, NULL, NULL },
5649 { jwin_ctext_proc, 237, 148-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_p, NULL, NULL },
5650 { jwin_ctext_proc, 237, 180-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex2, NULL, NULL },
5651 { jwin_ctext_proc, 237, 212-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex4, NULL, NULL },
5652 { jwin_ctext_proc, 92, 244-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_m, NULL, NULL },
5653 // 18
5654 { d_jbutton_proc, 22, 90-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "A", NULL, &Abtn},
5655 { d_jbutton_proc, 22, 118-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "B", NULL, &Bbtn},
5656 { d_jbutton_proc, 22, 146-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Start", NULL, &Sbtn},
5657 { d_jbutton_proc, 22, 178-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "X (EX1)", NULL, &Exbtn1},
5658 { d_jbutton_proc, 22, 210-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "EX3", NULL, &Exbtn3},
5659 { d_jbutton_proc, 167, 90-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "L", NULL, &Lbtn},
5660 { d_jbutton_proc, 167, 118-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "R", NULL, &Rbtn},
5661 { d_jbutton_proc, 167, 146-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Map", NULL, &Pbtn},
5662 { d_jbutton_proc, 167, 178-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Y (EX2)", NULL, &Exbtn2},
5663 { d_jbutton_proc, 167, 210-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "EX4", NULL, &Exbtn4},
5664 { d_jbutton_proc, 22, 242-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Menu", NULL, &Mbtn},
5665 // 29
5666 { d_j_clearbutton_proc, 22+91, 90-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Abtn},
5667 { d_j_clearbutton_proc, 22+91, 118-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Bbtn},
5668 { d_j_clearbutton_proc, 22+91, 146-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Sbtn},
5669 { d_j_clearbutton_proc, 22+91, 178-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exbtn1},
5670 { d_j_clearbutton_proc, 22+91, 210-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exbtn3},
5671 { d_j_clearbutton_proc, 167+91, 90-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Lbtn},
5672 { d_j_clearbutton_proc, 167+91, 118-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Rbtn},
5673 { d_j_clearbutton_proc, 167+91, 146-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Pbtn},
5674 { d_j_clearbutton_proc, 167+91, 178-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exbtn2},
5675 { d_j_clearbutton_proc, 167+91, 210-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exbtn4},
5676 { d_j_clearbutton_proc, 22+91, 242-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Mbtn},
5677 // 40
5678 { jwin_frame_proc, 14, 62, 147, 80, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5679 { jwin_frame_proc, 159, 62, 147, 80, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5680 { jwin_text_proc, 30, 68, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Vertical", NULL, NULL },
5681 { jwin_text_proc, 175, 68, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Horizontal", NULL, NULL },
5682 // 44
5683 { jwin_text_proc, 92, 84, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_up, NULL, NULL },
5684 { jwin_text_proc, 92, 112, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_down, NULL, NULL },
5685 { jwin_text_proc, 237, 84, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_left, NULL, NULL },
5686 { jwin_text_proc, 237, 112, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_right, NULL, NULL },
5687 // 48
5688 { d_jbutton_proc, 22, 82, 61, 21, vc(14), vc(11), 0, 0, 0, 0, (void *) "Up", NULL, &DUbtn },
5689 { d_jbutton_proc, 22, 110, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Down", NULL, &DDbtn },
5690 { d_jbutton_proc, 167, 82, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Left", NULL, &DLbtn },
5691 { d_jbutton_proc, 167, 110, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Right", NULL, &DRbtn },
5692 // 52
5693 { d_j_clearbutton_proc, 22+91, 82, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DUbtn},
5694 { d_j_clearbutton_proc, 22+91, 110, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DDbtn},
5695 { d_j_clearbutton_proc, 167+91, 82, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DLbtn},
5696 { d_j_clearbutton_proc, 167+91, 110, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DRbtn},
5697 // 56
5698 { jwin_check_proc, 22, 150, 147, 8, vc(14), vc(1), 0, 0, 1, 0, (void *) "Use Analog Stick/DPad", NULL, NULL },
5699 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5700 };
5701
5702 static int32_t keyboard_keys_list[] =
5703 {
5704 6,7,8,9,10,
5705 11,12,13,14,15,16,17,18,19,20,
5706 21,22,23,24,25,26,27,28,29,30,
5707 31,32,33,34,35,36,37,38,39,40,
5708 -1
5709 };
5710
5711 static int32_t keyboard_dirs_list[] =
5712 {
5713 41,42,43,44,
5714 45,46,47,48,
5715 49,50,51,52,
5716 53,54,55,56,
5717 -1
5718 };
5719
5720 static int32_t keyboard_mods_list[] =
5721 {
5722 57,58,59,60,
5723 61,62,63,64,
5724 65,66,67,68,
5725 69,70,71,72,
5726 -1
5727 };
5728
5729 static TABPANEL keyboard_control_tabs[] =
5730 {
5731 // (text)
5732 { (char *)"Keys", D_SELECTED, keyboard_keys_list, 0, NULL },
5733 { (char *)"Directions", 0, keyboard_dirs_list, 0, NULL },
5734 { (char *)"Cheat Mods", 0, keyboard_mods_list, 0, NULL },
5735 { NULL, 0, NULL, 0, NULL }
5736 };
5737
5738 static DIALOG keyboard_control_dlg[] =
5739 {
5740 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3)
5741 { jwin_win_proc, 8, 39, 304, 240, 0, 0, 0, D_EXIT, 0, 0, (void *) "Keyboard Controls", NULL, NULL },
5742 { jwin_tab_proc, 8+4, 39+23,304-8,240-56,vc(0), vc(15), 0, 0, 0, 0, (void *) keyboard_control_tabs, NULL, (void *)keyboard_control_dlg },
5743 { d_stringloader, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5744 { jwin_button_proc, 90, 254, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
5745 { jwin_button_proc, 170, 254, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
5746 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5747 // Keys
5748 // 6
5749 { jwin_frame_proc, 14, 80, 148, 105, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5750 { jwin_frame_proc, 158, 80, 148, 105, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5751 { jwin_frame_proc, 14, 181, 292, 67, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5752 { jwin_text_proc, 30, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Standard", NULL, NULL },
5753 { jwin_text_proc, 175, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Extended", NULL, NULL },
5754 // 11
5755 { jwin_text_proc, 92-4, 102, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_a, NULL, NULL },
5756 { jwin_text_proc, 92-4, 130, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_b, NULL, NULL },
5757 { jwin_text_proc, 92-4, 158, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_s, NULL, NULL },
5758 { jwin_text_proc, 92-4, 190, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex1, NULL, NULL },
5759 { jwin_text_proc, 92-4, 222, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex3, NULL, NULL },
5760 { jwin_text_proc, 237-4, 102, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_l, NULL, NULL },
5761 { jwin_text_proc, 237-4, 130, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_r, NULL, NULL },
5762 { jwin_text_proc, 237-4, 158, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_p, NULL, NULL },
5763 { jwin_text_proc, 237-4, 190, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex2, NULL, NULL },
5764 { jwin_text_proc, 237-4, 222, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex4, NULL, NULL },
5765 // 21
5766 { d_kbutton_proc, 22, 100, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "A", NULL, &Akey},
5767 { d_kbutton_proc, 22, 128, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "B", NULL, &Bkey},
5768 { d_kbutton_proc, 22, 156, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Start", NULL, &Skey},
5769 { d_kbutton_proc, 22, 188, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "X (EX1)", NULL, &Exkey1},
5770 { d_kbutton_proc, 22, 220, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "EX3", NULL, &Exkey3},
5771 { d_kbutton_proc, 167, 100, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "L", NULL, &Lkey},
5772 { d_kbutton_proc, 167, 128, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "R", NULL, &Rkey},
5773 { d_kbutton_proc, 167, 156, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Map", NULL, &Pkey},
5774 { d_kbutton_proc, 167, 188, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Y (EX2)", NULL, &Exkey2},
5775 { d_kbutton_proc, 167, 220, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "EX4", NULL, &Exkey4},
5776 // 31
5777 { d_k_clearbutton_proc, 22+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Akey},
5778 { d_k_clearbutton_proc, 22+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Bkey},
5779 { d_k_clearbutton_proc, 22+91, 156, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Skey},
5780 { d_k_clearbutton_proc, 22+91, 188, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exkey1},
5781 { d_k_clearbutton_proc, 22+91, 220, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exkey3},
5782 { d_k_clearbutton_proc, 167+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Lkey},
5783 { d_k_clearbutton_proc, 167+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Rkey},
5784 { d_k_clearbutton_proc, 167+91, 156, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Pkey},
5785 { d_k_clearbutton_proc, 167+91, 188, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exkey2},
5786 { d_k_clearbutton_proc, 167+91, 220, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exkey4},
5787 // Dirs
5788 // 41
5789 { jwin_frame_proc, 14, 80, 147, 80, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5790 { jwin_frame_proc, 159, 80, 147, 80, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5791 { jwin_text_proc, 30, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Vertical", NULL, NULL },
5792 { jwin_text_proc, 175, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Horizontal", NULL, NULL },
5793 // 45
5794 { jwin_text_proc, 92-4, 102, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_up, NULL, NULL },
5795 { jwin_text_proc, 92-4, 130, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_down, NULL, NULL },
5796 { jwin_text_proc, 237-4, 102, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_left, NULL, NULL },
5797 { jwin_text_proc, 237-4, 130, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_right, NULL, NULL },
5798 // 49
5799 { d_kbutton_proc, 22, 100, 61, 21, vc(14), vc(11), 0, 0, 0, 0, (void *) "Up", NULL, &DUkey},
5800 { d_kbutton_proc, 22, 128, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Down", NULL, &DDkey},
5801 { d_kbutton_proc, 167, 100, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Left", NULL, &DLkey},
5802 { d_kbutton_proc, 167, 128, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Right", NULL, &DRkey},
5803 // 53
5804 { d_k_clearbutton_proc, 22+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DUkey},
5805 { d_k_clearbutton_proc, 22+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DDkey},
5806 { d_k_clearbutton_proc, 167+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DLkey},
5807 { d_k_clearbutton_proc, 167+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DRkey},
5808 // Mods
5809 // 57
5810 { jwin_frame_proc, 14, 80, 148, 140-58, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5811 { jwin_frame_proc, 158, 80, 148, 140-58, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5812 { jwin_text_proc, 30, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Left", NULL, NULL },
5813 { jwin_text_proc, 175, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Right", NULL, NULL },
5814 // 61
5815 { jwin_text_proc, 92-26, 101, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_leftmod1, NULL, NULL },
5816 { jwin_text_proc, 92-26, 129, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_rightmod1, NULL, NULL },
5817 { jwin_text_proc, 237-4-22,101, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_leftmod2, NULL, NULL },
5818 { jwin_text_proc, 237-4-22,129, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_rightmod2, NULL, NULL },
5819 // 65
5820 { d_kbutton_proc, 22, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Main", NULL, &cheat_modifier_keys[0]},
5821 { d_kbutton_proc, 22, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Second", NULL, &cheat_modifier_keys[2]},
5822 { d_kbutton_proc, 167, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Main", NULL, &cheat_modifier_keys[1]},
5823 { d_kbutton_proc, 167, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Second", NULL, &cheat_modifier_keys[3]},
5824 // 69
5825 { d_k_clearbutton_proc, 22+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &cheat_modifier_keys[0]},
5826 { d_k_clearbutton_proc, 22+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &cheat_modifier_keys[2]},
5827 { d_k_clearbutton_proc, 167+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &cheat_modifier_keys[1]},
5828 { d_k_clearbutton_proc, 167+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &cheat_modifier_keys[3]},
5829 // 73
5830 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5831 };
5832
5833 /*
5834 int32_t midi_dp[3] = {0,147,104};
5835 int32_t digi_dp[3] = {1,147,120};
5836 int32_t pan_dp[3] = {0,147,136};
5837 int32_t buf_dp[3] = {0,147,152};
5838 */
5839 int32_t midi_dp[3] = {0,0,0};
5840 int32_t digi_dp[3] = {1,0,0};
5841 int32_t emus_dp[3] = {2,0,0};
5842 int32_t buf_dp[3] = {0,0,0};
5843 int32_t sfx_dp[3] = {3,0,0};
5844 int32_t pan_dp[3] = {0,0,0};
5845
5846 static DIALOG sound_dlg[] =
5847 {
5848 //(dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3)
5849 29 { jwin_win_proc, 0, 0, 320, 178, 0, 0, 0, D_EXIT, 0, 0, (void *) "Sound Settings", NULL, NULL },
5850 29 { d_stringloader, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5851 29 { jwin_button_proc, 58, 148, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
5852 29 { jwin_button_proc, 138, 148, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
5853 29 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5854 29 { jwin_frame_proc, 10, 28, 300, 112, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
5855 29 { jwin_rtext_proc, 190, 40, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_a, NULL, NULL },
5856 29 { jwin_rtext_proc, 190, 56, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_b, NULL, NULL },
5857 29 { jwin_rtext_proc, 190, 72, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_l, NULL, NULL },
5858 29 { jwin_rtext_proc, 190, 88, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_m, NULL, NULL },
5859 // 10
5860 29 { jwin_rtext_proc, 190, 104, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_r, NULL, NULL },
5861 29 { jwin_rtext_proc, 190, 120, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_s, NULL, NULL },
5862 29 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5863 29 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5864 29 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5865 29 { jwin_slider_proc, 196, 40, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 32, 0, NULL, (void *) set_vol, midi_dp },
5866 29 { jwin_slider_proc, 196, 56, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 32, 0, NULL, (void *) set_vol, digi_dp },
5867 29 { jwin_slider_proc, 196, 72, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 32, 0, NULL, (void *) set_vol, emus_dp },
5868 29 { jwin_slider_proc, 196, 88, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 127, 0, NULL, (void *) set_buf, buf_dp },
5869 29 { jwin_slider_proc, 196, 104, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 32, 0, NULL, (void *) set_vol, sfx_dp },
5870 //20
5871 29 { jwin_slider_proc, 196, 120, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 3, 0, NULL, (void *) set_pan, pan_dp },
5872 29 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5873 29 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5874 29 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5875 29 { jwin_text_proc, 17, 40, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Master MIDI Volume", NULL, NULL },
5876 29 { jwin_text_proc, 17, 56, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Master Digi Volume", NULL, NULL },
5877 29 { jwin_text_proc, 17, 72, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Enhanced Music Volume", NULL, NULL },
5878 29 { jwin_text_proc, 17, 88, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Enhanced Music Buffer", NULL, NULL },
5879 29 { jwin_text_proc, 17, 104, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "SFX Volume", NULL, NULL },
5880 29 { jwin_text_proc, 17, 120, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "SFX Pan", NULL, NULL },
5881 //30
5882 29 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5883 29 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5884 29 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5885 29 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5886 };
5887
5888 char zc_builddate[80];
5889 char zc_aboutstr[80];
5890
5891 static DIALOG about_dlg[] =
5892 {
5893 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
5894 { jwin_win_proc, 68, 52, 184, 154, 0, 0, 0, D_EXIT, 0, 0, (void *) "About", NULL, NULL },
5895 { jwin_button_proc, 140, 176, 41, 21, vc(14), 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
5896 { jwin_ctext_proc, 160, 84, 0, 8, vc(0), vc(11), 0, 0, 0, 0, zc_aboutstr, NULL, NULL },
5897 { jwin_ctext_proc, 160, 92, 0, 8, vc(0) , vc(11), 0, 0, 0, 0, str_s, NULL, NULL },
5898 { jwin_ctext_proc, 160, 100, 0, 8, vc(0) , vc(11), 0, 0, 0, 0, zc_builddate, NULL, NULL },
5899 { jwin_text_proc, 88, 124, 140, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Coded by:", NULL, NULL },
5900 { jwin_text_proc, 88, 132, 140, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) " Phantom Menace", NULL, NULL },
5901 { jwin_text_proc, 88, 144, 140, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Produced by:", NULL, NULL },
5902 { jwin_text_proc, 88, 152, 140, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) " Armageddon Games", NULL, NULL },
5903 { jwin_frame_proc, 80, 117, 160, 50, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5904 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5905 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5906 };
5907
5908
5909 static DIALOG quest_dlg[] =
5910 {
5911 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
5912 { jwin_win_proc, 68, 25, 184, 190, 0, 0, 0, D_EXIT, 0, 0, (void *) "Quest Info", NULL, NULL },
5913 { jwin_edit_proc, 84, 54, 152, 16, 0, 0, 0, D_READONLY, 100, 0, NULL, NULL, NULL },
5914 { jwin_text_proc, 89, 84, 141, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Number:", NULL, NULL },
5915 { jwin_text_proc, 152, 84, 24, 8, vc(7), vc(11), 0, 0, 0, 0, str_a, NULL, NULL },
5916 { jwin_text_proc, 89, 94, 141, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Version:", NULL, NULL },
5917 { jwin_text_proc, 160, 94, 64, 8, vc(7), vc(11), 0, 0, 0, 0, header_version_nul_term, NULL, NULL },
5918 { jwin_text_proc, 89, 104, 141, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "ZQ Version:", NULL, NULL },
5919 { jwin_text_proc, 184, 104, 64, 8, vc(7), vc(11), 0, 0, 0, 0, str_s, NULL, NULL },
5920 { jwin_text_proc, 84, 126, 80, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Title:", NULL, NULL },
5921 { jwin_textbox_proc, 84, 136, 152, 24, 0, 0, 0, 0, 0, 0, QHeader.title, NULL, NULL },
5922 { jwin_text_proc, 84, 168, 80, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Author:", NULL, NULL },
5923 { jwin_textbox_proc, 84, 178, 152, 24, 0, 0, 0, 0, 0, 0, QHeader.author, NULL, NULL },
5924 { jwin_frame_proc, 84, 79, 152, 38, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5925 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5926 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5927 };
5928
5929 static DIALOG triforce_dlg[] =
5930 {
5931 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
5932 { jwin_win_proc, 72, 64, 177, 105, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Triforce Pieces", NULL, NULL },
5933 // 1
5934 { jwin_check_proc, 129, 94, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "1", NULL, NULL },
5935 { jwin_check_proc, 129, 104, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "2", NULL, NULL },
5936 { jwin_check_proc, 129, 114, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "3", NULL, NULL },
5937 { jwin_check_proc, 129, 124, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "4", NULL, NULL },
5938 { jwin_check_proc, 172, 94, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "5", NULL, NULL },
5939 { jwin_check_proc, 172, 104, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "6", NULL, NULL },
5940 { jwin_check_proc, 172, 114, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "7", NULL, NULL },
5941 { jwin_check_proc, 172, 124, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "8", NULL, NULL },
5942 // 9
5943 { jwin_button_proc, 90, 144, 61, 21, vc(0), vc(11), 'k', D_EXIT, 0, 0, (void *) "O&K", NULL, NULL },
5944 { jwin_button_proc, 170, 144, 61, 21, vc(0), vc(11), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
5945 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5946 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5947 };
5948
5949 bool zc_getname(const char *prompt,const char *ext,EXT_LIST *list,const char *def,bool usefilename)
5950 {
5951 go();
5952 int32_t ret=0;
5953 ret = zc_getname_nogo(prompt,ext,list,def,usefilename);
5954 comeback();
5955 return ret != 0;
5956 }
5957
5958
5959 bool zc_getname_nogo(const char *prompt,const char *ext,EXT_LIST *list,const char *def,bool usefilename)
5960 {
5961 if(def!=modulepath)
5962 strcpy(modulepath,def);
5963
5964 if(!usefilename)
5965 {
5966 int32_t i=(int32_t)strlen(modulepath);
5967
5968 while(i>=0 && modulepath[i]!='\\' && modulepath[i]!='/')
5969 modulepath[i--]=0;
5970 }
5971
5972 // int32_t ret = file_select_ex(prompt,modulepath,ext,255,-1,-1);
5973 int32_t ret=0;
5974 int32_t sel=0;
5975
5976 if(list==NULL)
5977 {
5978 ret = jwin_file_select_ex(prompt,modulepath,ext,2048,-1,-1,lfont);
5979 }
5980 else
5981 {
5982 ret = jwin_file_browse_ex(prompt, modulepath, list, &sel, 2048, -1, -1, lfont);
5983 }
5984
5985 return ret!=0;
5986 }
5987
5988 //The Dialogue that loads a ZMOD Module File
5989 int32_t zc_load_zmod_module_file()
5990 {
5991 if ( Playing )
5992 {
5993 jwin_alert("Error","Cannot change module while playing a quest!",NULL,NULL,"O&K",NULL,'k',0,lfont);
5994 return -1;
5995 }
5996 if(!zc_getname("Load Module (.zmod)","zmod",NULL,modulepath,false))
5997 return D_CLOSE;
5998
5999 FILE *tempmodule = fopen(modulepath,"r");
6000
6001 if(tempmodule == NULL)
6002 {
6003 jwin_alert("Error","Cannot open specified file!",NULL,NULL,"O&K",NULL,'k',0,lfont);
6004 return -1;
6005 }
6006
6007
6008 //Set the module path:
6009 memset(moduledata.module_name, 0, sizeof(moduledata.module_name));
6010 strcpy(moduledata.module_name, modulepath);
6011 al_trace("New Module Path is: %s \n", moduledata.module_name);
6012 zc_set_config("ZCMODULE","current_module",moduledata.module_name);
6013 zcm.init(true); //Load the module values.
6014 moduledata.refresh_title_screen = 1;
6015 // refresh_select_screen = 1;
6016 build_biic_list();
6017 return D_O_K;
6018 }
6019
6020 static DIALOG module_info_dlg[] =
6021 {
6022 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
6023
6024
6025 { jwin_win_proc, 0, 0, 200, 200, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "About Current Module", NULL, NULL },
6026 //1
6027 { jwin_text_proc, 10, 20, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"Module:", NULL, NULL },
6028 //2
6029 { jwin_text_proc, 50, 20, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6030 { jwin_text_proc, 10, 30, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"Author:", NULL, NULL },
6031 //4
6032 { jwin_text_proc, 50, 30, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6033 { jwin_text_proc, 10, 40, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6034 { jwin_text_proc, 10, 50, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"Information:", NULL, NULL },
6035 //7
6036
6037 { jwin_text_proc, 10, 60, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6038 { jwin_text_proc, 10, 70, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6039 { jwin_text_proc, 10, 80, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6040 { jwin_text_proc, 10, 90, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6041 { jwin_text_proc, 10, 100, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6042 { jwin_text_proc, 10, 120, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6043 { jwin_text_proc, 10, 130, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6044 { jwin_text_proc, 10, 140, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6045 { jwin_text_proc, 10, 150, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6046
6047 { jwin_button_proc, 40, 160, 50, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
6048 { jwin_button_proc, 200-40-50, 160, 50, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
6049 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6050 };
6051
6052 void about_zcplayer_module(const char *prompt,int32_t initialval)
6053 {
6054
6055 module_info_dlg[0].dp2 = lfont;
6056 if ( moduledata.moduletitle[0] != 0 )
6057 module_info_dlg[2].dp = (char*)moduledata.moduletitle;
6058
6059 if ( moduledata.moduleauthor[0] != 0 )
6060 module_info_dlg[4].dp = (char*)moduledata.moduleauthor;
6061
6062 if ( moduledata.moduleinfo0[0] != 0 )
6063 module_info_dlg[7].dp = (char*)moduledata.moduleinfo0;
6064 if ( moduledata.moduleinfo1[0] != 0 )
6065 module_info_dlg[8].dp = (char*)moduledata.moduleinfo1;
6066 if ( moduledata.moduleinfo2[0] != 0 )
6067 module_info_dlg[9].dp = (char*)moduledata.moduleinfo2;
6068 if ( moduledata.moduleinfo3[0] != 0 )
6069 module_info_dlg[10].dp = (char*)moduledata.moduleinfo3;
6070 if ( moduledata.moduleinfo4[0] != 0 )
6071 module_info_dlg[11].dp = (char*)moduledata.moduleinfo4;
6072
6073 char module_date[255];
6074 memset(module_date, 0, sizeof(module_date));
6075 sprintf(module_date,"Build Date: %s %s, %d at @ %d:%d %s", dayextension(moduledata.modday).c_str(),
6076 (char*)months[moduledata.modmonth], moduledata.modyear, moduledata.modhour, moduledata.modminute, moduledata.moduletimezone);
6077
6078
6079
6080 char module_vers[255];
6081 memset(module_vers, 0, sizeof(module_vers));
6082 sprintf(module_vers, "Version: %d.%d.%d.%d", moduledata.modver_1, moduledata.modver_2, moduledata.modver_3, moduledata.modver_4);
6083
6084
6085 //sprintf(tilecount,"%d",1);
6086
6087 char module_build[255];
6088 memset(module_build, 0, sizeof(module_build));
6089 if ( moduledata.modbeta )
6090 sprintf(module_build,"Module Build: %d, %s: %d", moduledata.modbuild, (moduledata.modbeta<0) ? "Alpha" : "Beta", moduledata.modbeta );
6091 else
6092 sprintf(module_build,"Module Build: %d", moduledata.modbuild);
6093
6094 module_info_dlg[12].dp = (char*)module_date;
6095 module_info_dlg[13].dp = (char*)module_vers;
6096 module_info_dlg[14].dp = (char*)module_build;
6097
6098 large_dialog(module_info_dlg);
6099
6100 int32_t ret = zc_popup_dialog(module_info_dlg,-1);
6101 jwin_center_dialog(module_info_dlg);
6102
6103
6104 }
6105
6106 int32_t onAbout_ZCP_Module()
6107 {
6108 about_zcplayer_module("About Module (.zmod)", 0);
6109 return D_O_K;
6110 }
6111
6112 //New Modules Menu for 2.55+
6113 static MENU zcmodule_menu[] =
6114 {
6115 { (char *)"&Load Module...", zc_load_zmod_module_file, NULL, 0, NULL },
6116 { (char *)"&About Module", onAbout_ZCP_Module, NULL, 0, NULL },
6117
6118 { NULL, NULL, NULL, 0, NULL }
6119 };
6120
6121 int32_t onToggleRecordingNewSaves()
6122 {
6123 if (zc_get_config("zeldadx", "replay_new_saves", false))
6124 {
6125 zc_set_config("zeldadx", "replay_new_saves", false);
6126 }
6127 else
6128 {
6129 zc_set_config("zeldadx", "replay_new_saves", true);
6130 jwin_alert("Recording", "Newly created saves will be recorded and written to a replay file.",
6131 NULL,NULL,"OK",NULL,13,27,lfont);
6132 }
6133 return D_O_K;
6134 }
6135
6136 int32_t onToggleSnapshotAllFrames()
6137 {
6138 replay_set_snapshot_all_frames(!replay_is_snapshot_all_frames());
6139 return D_O_K;
6140 }
6141
6142 int32_t onStopReplayOrRecord()
6143 {
6144 if (replay_is_replaying())
6145 {
6146 replay_quit();
6147 }
6148 else if (replay_get_mode() == ReplayMode::Record)
6149 {
6150 if (!replay_get_meta_bool("test_mode"))
6151 {
6152 jwin_alert("Recording", "You cannot stop recording a save file.",
6153 NULL,NULL,"OK",NULL,13,27,lfont);
6154 return D_CLOSE;
6155 }
6156
6157 if (jwin_alert("Stop Recording",
6158 "Save replay to disk and stop recording?",
6159 "This will stop the recording.",
6160 NULL,
6161 "Yes","No",13,27,lfont) != 1)
6162 return D_CLOSE;
6163
6164 replay_save();
6165 replay_stop();
6166 }
6167 return D_O_K;
6168 }
6169
6170 static int32_t handle_on_load_replay(ReplayMode mode)
6171 {
6172 if (Playing)
6173 {
6174 if (jwin_alert("Replay - Warning!",
6175 "Loading a replay will exit the current game.",
6176 "All unsaved progress will be lost.",
6177 "Do you wish to continue?",
6178 "Yes","No",13,27,lfont) != 1)
6179 return D_CLOSE;
6180 }
6181
6182 std::string mode_string = replay_mode_to_string(mode);
6183 mode_string[0] = std::toupper(mode_string[0]);
6184
6185 std::string line_1 = "Select a replay file to play back.";
6186 std::string line_2 = "You won't be able to save, and it won't effect existing saves.";
6187 std::string line_3 = "You can stop the replay and take over manually any time.";
6188 if (mode == ReplayMode::Update)
6189 {
6190 line_1 = "Select a replay file to update.";
6191 line_2 = "WARNING: be sure to back up the zplay file";
6192 line_3 = "and verify that the updated replay works as expected!";
6193 }
6194
6195 if (jwin_alert(mode_string.c_str(),
6196 line_1.c_str(),
6197 line_2.c_str(),
6198 line_3.c_str(),
6199 "OK","Nevermind",13,27,lfont) == 1)
6200 {
6201 char replay_path[2048];
6202 strcpy(replay_path, "replays/");
6203 if (jwin_file_select_ex(
6204 fmt::format("Load Replay (.{})", REPLAY_EXTENSION).c_str(),
6205 replay_path, REPLAY_EXTENSION.c_str(), 2048, -1, -1, lfont) == 0)
6206 return D_CLOSE;
6207
6208 replay_quit();
6209 load_replay_file_deferred(mode, replay_path);
6210 Quit = qRESET;
6211 return D_CLOSE;
6212 }
6213 return D_O_K;
6214 }
6215
6216 int32_t onLoadReplay()
6217 {
6218 return handle_on_load_replay(ReplayMode::Replay);
6219 }
6220
6221 int32_t onLoadReplayAssert()
6222 {
6223 return handle_on_load_replay(ReplayMode::Assert);
6224 }
6225
6226 int32_t onLoadReplayUpdate()
6227 {
6228 return handle_on_load_replay(ReplayMode::Update);
6229 }
6230
6231 int32_t onSaveReplay()
6232 {
6233 if (replay_get_mode() == ReplayMode::Record)
6234 {
6235 if (!replay_get_meta_bool("test_mode"))
6236 {
6237 if (jwin_alert("Save Replay",
6238 "This will save a copy of the replay up to this point.",
6239 "The official replay file will be untouched.",
6240 "Do you wish to continue?",
6241 "Yes","No",13,27,lfont) != 1)
6242 return D_CLOSE;
6243
6244 char replay_path[2048];
6245 strcpy(replay_path, replay_get_replay_path().string().c_str());
6246 if (jwin_file_select_ex(
6247 fmt::format("Save Replay (.{})", REPLAY_EXTENSION).c_str(),
6248 replay_path, REPLAY_EXTENSION.c_str(), 2048, -1, -1, lfont) == 0)
6249 return D_CLOSE;
6250
6251 if (fileexists(replay_path))
6252 {
6253 jwin_alert("Save Replay", "You cannot overwrite an existing file.",
6254 NULL,NULL,"OK",NULL,13,27,lfont);
6255 return D_CLOSE;
6256 }
6257
6258 replay_save(replay_path);
6259 }
6260 else
6261 {
6262 replay_save();
6263 }
6264 }
6265 return D_O_K;
6266 }
6267
6268 static MENU replay_menu[] =
6269 {
6270 { (char *)"Record new saves", onToggleRecordingNewSaves, NULL, 0, NULL },
6271 { (char *)"Stop replay", onStopReplayOrRecord, NULL, 0, NULL },
6272 { (char *)"Load replay", onLoadReplay, NULL, 0, NULL },
6273 { (char *)"Load replay (assert)", onLoadReplayAssert, NULL, 0, NULL },
6274 { (char *)"Load replay (update)", onLoadReplayUpdate, NULL, 0, NULL },
6275 { (char *)"Save replay", onSaveReplay, NULL, 0, NULL },
6276 { (char *)"Enable snapshot all frames", onToggleSnapshotAllFrames,NULL, 0, NULL },
6277
6278 { NULL, NULL, NULL, 0, NULL }
6279 };
6280
6281 static DIALOG credits_dlg[] =
6282 {
6283 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
6284 { jwin_win_proc, 40, 38, 241, 173, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Zelda Classic Credits", NULL, NULL },
6285 { jwin_frame_proc, 47, 65, 227, 115, vc(15), vc(1), 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
6286 { d_bitmap_proc, 49, 67, 222, 110, vc(15), vc(1), 0, 0, 0, 0, NULL, NULL, NULL },
6287 { jwin_button_proc, 140, 184, 41, 21, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
6288 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6289 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6290 };
6291
6292 29 static ListData dmap_list(dmaplist, &font, &a5font);
6293
6294 static DIALOG goto_dlg[] =
6295 {
6296 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
6297 { jwin_win_proc, 48, 25, 205, 100, 0, 0, 0, D_EXIT, 0, 0, (void *) "Goto Location", NULL, NULL },
6298 { jwin_button_proc, 90, 176-78, 61, 21, vc(14), 0, 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
6299 { jwin_button_proc, 170, 176-78, 61, 21, vc(14), 0, 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
6300 { jwin_text_proc, 55, 129-75, 80, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "DMap:", NULL, NULL },
6301 { jwin_droplist_proc, 88, 126-75, 160, 16, 0, 0, 0, 0, 0, 0, (void *) &dmap_list, NULL, NULL },
6302 { jwin_text_proc, 55, 149-75, 80, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Screen:", NULL, NULL },
6303 { jwin_edit_proc, 132, 146-75, 91, 16, 0, 0, 0, 0, 2, 0, NULL, NULL, NULL },
6304 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6305 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6306 };
6307
6308 int32_t onGoTo()
6309 {
6310 bool music = false;
6311 music = music;
6312 sprintf(cheat_goto_screen_str,"%X",cheat_goto_screen);
6313
6314 goto_dlg[0].dp2=lfont;
6315 goto_dlg[4].d2=cheat_goto_dmap;
6316 goto_dlg[6].dp=cheat_goto_screen_str;
6317
6318 clear_keybuf();
6319
6320 large_dialog(goto_dlg);
6321
6322 if(zc_popup_dialog(goto_dlg,4)==1)
6323 {
6324 // dmap, screen
6325 cheats_enqueue(Cheat::GoTo, goto_dlg[4].d2, zc_min(zc_xtoi(cheat_goto_screen_str),0x7F));
6326 };
6327
6328 return D_O_K;
6329 }
6330
6331 int32_t onGoToComplete()
6332 {
6333 if(!Playing)
6334 {
6335 return D_O_K;
6336 }
6337
6338 system_pal();
6339 music_pause();
6340 pause_all_sfx();
6341 show_mouse(screen);
6342 onGoTo();
6343 eat_buttons();
6344
6345 zc_readrawkey(KEY_ESC);
6346
6347 show_mouse(NULL);
6348 game_pal();
6349 music_resume();
6350 resume_all_sfx();
6351 return D_O_K;
6352 }
6353
6354 int32_t onCredits()
6355 {
6356 go();
6357
6358 BITMAP *win = create_bitmap_ex(8,222,110);
6359
6360 if(!win)
6361 return D_O_K;
6362
6363 int32_t c=0;
6364 int32_t l=0;
6365 int32_t ol=-1;
6366 RLE_SPRITE *rle = (RLE_SPRITE*)(datafile[RLE_CREDITS].dat);
6367 RGB *pal = (RGB*)(datafile[PAL_CREDITS].dat);
6368 PALETTE tmppal;
6369
6370 rti_gui.transparency_index = 1;
6371
6372 clear_to_color(win, rti_gui.transparency_index);
6373 draw_rle_sprite(win,rle,0,0);
6374 credits_dlg[0].dp2=lfont;
6375 credits_dlg[1].fg = jwin_pal[jcDISABLED_FG];
6376 credits_dlg[2].dp = win;
6377
6378 set_palette_range(black_palette,0,127,false);
6379
6380 DIALOG_PLAYER *p = init_dialog(credits_dlg,3);
6381
6382 BITMAP* old_screen = screen;
6383 BITMAP* gui_bmp = zc_get_gui_bmp();
6384 ASSERT(gui_bmp);
6385 clear_to_color(gui_bmp, rti_gui.transparency_index);
6386 screen = gui_bmp;
6387
6388 while(update_dialog(p))
6389 {
6390 throttleFPS();
6391 ++c;
6392 l = zc_max((c>>1)-30,0);
6393
6394 if(l > rle->h)
6395 l = c = 0;
6396
6397 if(l > rle->h - 112)
6398 l = rle->h - 112;
6399
6400 clear_bitmap(win);
6401 draw_rle_sprite(win,rle,0,0-l);
6402
6403 if(c<=64)
6404 fade_interpolate(black_palette,pal,tmppal,c,0,127);
6405
6406 set_palette_range(tmppal,0,127,false);
6407
6408 if(l!=ol)
6409 {
6410 scare_mouse();
6411 d_bitmap_proc(MSG_DRAW,credits_dlg+2,0);
6412 unscare_mouse();
6413 SCRFIX();
6414 ol=l;
6415 }
6416
6417 update_hw_screen();
6418 }
6419
6420 screen = old_screen;
6421 system_pal();
6422
6423 shutdown_dialog(p);
6424 destroy_bitmap(win);
6425 //comeback();
6426
6427 rti_gui.transparency_index = 0;
6428
6429 return D_O_K;
6430 }
6431
6432 const char *midilist(int32_t index, int32_t *list_size)
6433 {
6434 if(index<0)
6435 {
6436 *list_size=0;
6437
6438 for(int32_t i=0; i<MAXMIDIS; i++)
6439 if(tunes[i].data)
6440 ++(*list_size);
6441
6442 return NULL;
6443 }
6444
6445 int32_t i=0,m=0;
6446
6447 while(m<=index && i<=MAXMIDIS)
6448 {
6449 if(tunes[i].data)
6450 ++m;
6451
6452 ++i;
6453 }
6454
6455 --i;
6456
6457 if(i==MAXMIDIS && m<index)
6458 return "(null)";
6459
6460 return tunes[i].title;
6461 }
6462
6463 /* ------- MIDI info stuff -------- */
6464
6465 char *text;
6466 midi_info *zmi;
6467 bool dialog_running;
6468 bool listening;
6469
6470 void get_info(int32_t index);
6471
6472 int32_t d_midilist_proc(int32_t msg,DIALOG *d,int32_t c)
6473 {
6474 int32_t d2 = d->d2;
6475 int32_t ret = jwin_droplist_proc(msg,d,c);
6476
6477 if(d2!=d->d2)
6478 {
6479 get_info(d->d2);
6480 }
6481
6482 return ret;
6483 }
6484
6485 int32_t d_listen_proc(int32_t msg,DIALOG *d,int32_t c)
6486 {
6487 /* 'd->d1' is offset from 'd' in DIALOG array to midilist proc */
6488
6489 int32_t ret = jwin_button_proc(msg,d,c);
6490
6491 if(ret == D_CLOSE)
6492 {
6493 // get current midi index
6494 int32_t index = (d+(d->d1))->d2;
6495 int32_t i=0, m=0;
6496
6497 while(m<=index && i<=MAXMIDIS)
6498 {
6499 if(tunes[i].data)
6500 ++m;
6501
6502 ++i;
6503 }
6504
6505 --i;
6506 jukebox(i);
6507 listening = true;
6508 ret = D_O_K;
6509 }
6510
6511 return ret;
6512 }
6513
6514 int32_t d_savemidi_proc(int32_t msg,DIALOG *d,int32_t c)
6515 {
6516 /* 'd->d1' is offset from 'd' in DIALOG array to midilist proc */
6517
6518 int32_t ret = jwin_button_proc(msg,d,c);
6519
6520 if(ret == D_CLOSE)
6521 {
6522 // get current midi index
6523 int32_t index = (d+(d->d1))->d2;
6524 int32_t i=0, m=0;
6525
6526 while(m<=index && i<=MAXMIDIS)
6527 {
6528 if(tunes[i].data)
6529 ++m;
6530
6531 ++i;
6532 }
6533
6534 --i;
6535
6536 // get file name
6537
6538 int32_t sel=0;
6539 //struct ffblk f;
6540 char title[40] = "Save MIDI: ";
6541 char fname[2048];
6542 memset(fname,0,2048);
6543 static EXT_LIST list[] =
6544 {
6545 { (char *)"MIDI files (*.mid)", (char *)"mid" },
6546 { (char *)"HTML files (*.html, *.html)", (char *)"htm html" },
6547 { NULL, NULL }
6548 };
6549
6550 strcpy(title+11, tunes[i].title);
6551 title[39] = '\0';
6552
6553 if(jwin_file_browse_ex(title, fname, list, &sel, 2048, -1, -1, lfont)==0)
6554 goto done;
6555
6556 if(exists(fname))
6557 {
6558 if(jwin_alert(title, fname, "already exists.", "Overwrite it?", "&Yes","&No",'y','n',lfont)==2)
6559 goto done;
6560 }
6561
6562 // save midi i
6563
6564 if(save_midi(fname, (MIDI*)tunes[i].data) != 0)
6565 jwin_alert(title, "Error saving MIDI to", fname, NULL, "Darn", NULL,13,27,lfont);
6566
6567 done:
6568 chop_path(fname);
6569 ret = D_REDRAW;
6570 }
6571
6572 return ret;
6573 }
6574
6575 29 static ListData midi_list(midilist, &font, &a5font);
6576
6577 static DIALOG midi_dlg[] =
6578 {
6579 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
6580 { jwin_win_proc, 8, 28, 304, 184, 0, 0, 0, D_EXIT, 0, 0, (void *) "MIDI Info", NULL, NULL },
6581 { jwin_text_proc, 32, 60, 40, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Tune:", NULL, NULL },
6582 { d_midilist_proc, 80, 56, 192, 16, 0, 0, 0, 0, 0, 0, (void *) &midi_list, NULL, NULL },
6583 { jwin_textbox_proc, 15, 80, 290, 96, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6584 { d_listen_proc, 24, 183, 72, 21, 0, 0, 'l', D_EXIT, -2, 0, (void *) "&Listen", NULL, NULL },
6585 { d_savemidi_proc, 108, 183, 72, 21, 0, 0, 's', D_EXIT, -3, 0, (void *) "&Save", NULL, NULL },
6586 { jwin_button_proc, 236, 183, 61, 21, 0, 0, 'k', D_EXIT, 0, 0, (void *) "O&K", NULL, NULL },
6587 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6588 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6589 };
6590
6591 void get_info(int32_t index)
6592 {
6593 int32_t i=0, m=0;
6594
6595 while(m<=index && i<=MAXMIDIS)
6596 {
6597 if(tunes[i].data)
6598 ++m;
6599
6600 ++i;
6601 }
6602
6603 --i;
6604
6605 if(i==MAXMIDIS && m<index)
6606 strcpy(text,"(null)");
6607 else
6608 {
6609 get_midi_info((MIDI*)tunes[i].data,zmi);
6610 get_midi_text((MIDI*)tunes[i].data,zmi,text);
6611 }
6612
6613 midi_dlg[0].dp2=lfont;
6614 midi_dlg[3].dp = text;
6615 midi_dlg[3].d1 = midi_dlg[3].d2 = 0;
6616 midi_dlg[5].flags = (tunes[i].flags&tfDISABLESAVE) ? D_DISABLED : D_EXIT;
6617
6618 if(dialog_running)
6619 {
6620 scare_mouse();
6621 jwin_textbox_proc(MSG_DRAW,midi_dlg+3,0);
6622 d_savemidi_proc(MSG_DRAW,midi_dlg+5,0);
6623 unscare_mouse();
6624 }
6625 }
6626
6627 int32_t onMIDICredits()
6628 {
6629 text = (char*)malloc(4096);
6630 zmi = (midi_info*)malloc(sizeof(midi_info));
6631
6632 if(!text || !zmi)
6633 {
6634 jwin_alert(NULL,"Not enough memory",NULL,NULL,"OK",NULL,13,27,lfont);
6635 return D_O_K;
6636 }
6637
6638 bool do_pause_midi = midi_pos >= 0 && currmidi;
6639 auto restore_midi = currmidi;
6640 if(do_pause_midi)
6641 {
6642 paused_midi_pos = midi_pos;
6643 stop_midi();
6644 midi_paused=true;
6645 midi_suspended = midissuspHALTED;
6646 }
6647
6648 midi_dlg[0].dp2=lfont;
6649 midi_dlg[2].d1 = 0;
6650 midi_dlg[2].d2 = 0;
6651 midi_dlg[4].flags = D_EXIT;
6652 midi_dlg[5].flags = (tunes[midi_dlg[2].d1].flags&tfDISABLESAVE) ? D_DISABLED : D_EXIT;
6653
6654 listening = false;
6655 dialog_running=false;
6656 get_info(0);
6657
6658 dialog_running=true;
6659
6660 large_dialog(midi_dlg);
6661
6662 zc_popup_dialog(midi_dlg,0);
6663 dialog_running=false;
6664
6665 if(listening)
6666 music_stop();
6667
6668 if(do_pause_midi)
6669 {
6670 midi_suspended = midissuspRESUME;
6671 currmidi = restore_midi;
6672 midi_pos = paused_midi_pos;
6673 }
6674
6675 if(text) free(text);
6676 if(zmi) free(zmi);
6677 return D_O_K;
6678 }
6679
6680 int32_t onAbout()
6681 {
6682 char buf1[80]={0};
6683 std::ostringstream oss;
6684 sprintf(buf1,"%s (%s), Version: %s", ZC_PLAYER_NAME,PROJECT_NAME,ZC_PLAYER_V);
6685 oss << buf1 << '\n';
6686 sprintf(buf1, "%s, Build %d", ALPHA_VER_STR, VERSION_BUILD);
6687 oss << buf1 << '\n';
6688 sprintf(buf1,"Build Date: %s %s, %d at @ %s %s", dayextension(BUILDTM_DAY).c_str(), (char*)months[BUILDTM_MONTH], BUILDTM_YEAR, __TIME__, __TIMEZONE__);
6689 oss << buf1 << '\n';
6690 sprintf(buf1, "Built By: %s", DEV_SIGNOFF);
6691 oss << buf1 << '\n';
6692 sprintf(buf1, "Tag: %s", getReleaseTag());
6693 oss << buf1 << '\n';
6694
6695 InfoDialog("About ZC", oss.str()).show();
6696 return D_O_K;
6697 }
6698
6699 int32_t onQuest()
6700 {
6701 char fname[100];
6702 strcpy(fname, get_filename(qstpath));
6703 quest_dlg[0].dp2=lfont;
6704 quest_dlg[1].dp = fname;
6705
6706 if(QHeader.quest_number==0)
6707 sprintf(str_a,"Custom");
6708 else
6709 sprintf(str_a,"%d",QHeader.quest_number);
6710
6711 sprintf(str_s,"%s",VerStr(QHeader.zelda_version));
6712
6713 quest_dlg[11].d1 = quest_dlg[9].d1 = 0;
6714 quest_dlg[11].d2 = quest_dlg[9].d2 = 0;
6715
6716 large_dialog(quest_dlg);
6717
6718 zc_popup_dialog(quest_dlg, 0);
6719 return D_O_K;
6720 }
6721
6722 void call_vidmode_dlg();
6723 int32_t onVidMode()
6724 {
6725 call_vidmode_dlg();
6726 return D_O_K;
6727 }
6728
6729 #define addToHash(c,b,h) if(h->find(c ## key) == h->end()) \
6730 {(*h)[c ## key]=true;} else { if ( c ## key != 0 ) b = false;}
6731 //Added an extra statement, so that if the key is cleared to 0, the cleared
6732 //keybinding status need not be unique. -Z ( 1st April, 2019 )
6733
6734 void load_ukeys(int32_t* arr)
6735 {
6736 arr[ukey_a] = Akey;
6737 arr[ukey_b] = Bkey;
6738 arr[ukey_s] = Skey;
6739 arr[ukey_l] = Lkey;
6740 arr[ukey_r] = Rkey;
6741 arr[ukey_p] = Pkey;
6742 arr[ukey_ex1] = Exkey1;
6743 arr[ukey_ex2] = Exkey2;
6744 arr[ukey_ex3] = Exkey3;
6745 arr[ukey_ex4] = Exkey4;
6746 arr[ukey_du] = DUkey;
6747 arr[ukey_dd] = DDkey;
6748 arr[ukey_dl] = DLkey;
6749 arr[ukey_dr] = DRkey;
6750 arr[ukey_mod1a] = cheat_modifier_keys[0];
6751 arr[ukey_mod1b] = cheat_modifier_keys[1];
6752 arr[ukey_mod2a] = cheat_modifier_keys[2];
6753 arr[ukey_mod2b] = cheat_modifier_keys[3];
6754 };
6755
6756 static const char* ukey_names[] = {
6757 "A", "B", "Start", "L", "R", "Map",
6758 "Ex1", "Ex2", "Ex3", "Ex4", "Up", "Down",
6759 "Left", "Right", "Cheat Mod L1", "Cheat Mod L2",
6760 "Cheat Mod R1", "Cheat Mod R2",
6761 };
6762 std::string get_ukey_name(int32_t k)
6763 {
6764 if (k < num_ukey) return ukey_names[k];
6765 return "";
6766 }
6767
6768 int32_t onKeyboard()
6769 {
6770 int32_t a = Akey;
6771 int32_t b = Bkey;
6772 int32_t s = Skey;
6773 int32_t l = Lkey;
6774 int32_t r = Rkey;
6775 int32_t p = Pkey;
6776 int32_t ex1 = Exkey1;
6777 int32_t ex2 = Exkey2;
6778 int32_t ex3 = Exkey3;
6779 int32_t ex4 = Exkey4;
6780 int32_t du = DUkey;
6781 int32_t dd = DDkey;
6782 int32_t dl = DLkey;
6783 int32_t dr = DRkey;
6784 int32_t mod1a = cheat_modifier_keys[0];
6785 int32_t mod1b = cheat_modifier_keys[1];
6786 int32_t mod2a = cheat_modifier_keys[2];
6787 int32_t mod2b = cheat_modifier_keys[3];
6788 bool done=false;
6789 int32_t ret;
6790
6791 keyboard_control_dlg[0].dp2=lfont;
6792
6793 large_dialog(keyboard_control_dlg);
6794
6795 while(!done)
6796 {
6797 ret = zc_popup_dialog(keyboard_control_dlg,3);
6798
6799 if(ret==3) // OK
6800 {
6801 int32_t ukeys[num_ukey];
6802 load_ukeys(ukeys);
6803 std::vector<std::string> uniqueError;
6804 for(int32_t q = 0; q < num_ukey; ++q)
6805 {
6806 for(int32_t p = q+1; p < num_ukey; ++p)
6807 {
6808 if(ukeys[q] == ukeys[p] && ukeys[q] != 0)
6809 {
6810 char buf[64];
6811 sprintf(buf, "'%s' conflicts with '%s'", get_ukey_name(q).c_str(), get_ukey_name(p).c_str());
6812 std::string str(buf);
6813 uniqueError.push_back(str);
6814 }
6815 }
6816 }
6817 if(uniqueError.size() == 0)
6818 {
6819 done = true;
6820 save_control_configs(true);
6821 }
6822 else
6823 {
6824 box_start(1, "Duplicate Keys", lfont, sfont, false, keyboard_control_dlg[0].w,keyboard_control_dlg[0].h, 2);
6825 box_out("Cannot have duplicate keybinds!"); box_eol();
6826 for(std::vector<std::string>::iterator it = uniqueError.begin();
6827 it != uniqueError.end(); ++it)
6828 {
6829 box_out((*it).c_str()); box_eol();
6830 }
6831 box_end(true);
6832 }
6833 }
6834 else // Cancel
6835 {
6836 Akey = a;
6837 Bkey = b;
6838 Skey = s;
6839 Lkey = l;
6840 Rkey = r;
6841 Pkey = p;
6842 Exkey1 = ex1;
6843 Exkey2 = ex2;
6844 Exkey3 = ex3;
6845 Exkey4 = ex4;
6846 DUkey = du;
6847 DDkey = dd;
6848 DLkey = dl;
6849 DRkey = dr;
6850 cheat_modifier_keys[0] = mod1a;
6851 cheat_modifier_keys[1] = mod1b;
6852 cheat_modifier_keys[2] = mod2a;
6853 cheat_modifier_keys[3] = mod2b;
6854
6855 done=true;
6856 }
6857
6858 rest(1);
6859 }
6860
6861 return D_O_K;
6862 }
6863
6864 int32_t onGamepad()
6865 {
6866 int32_t a = Abtn;
6867 int32_t b = Bbtn;
6868 int32_t s = Sbtn;
6869 int32_t l = Lbtn;
6870 int32_t r = Rbtn;
6871 int32_t m = Mbtn;
6872 int32_t p = Pbtn;
6873 int32_t ex1 = Exbtn1;
6874 int32_t ex2 = Exbtn2;
6875 int32_t ex3 = Exbtn3;
6876 int32_t ex4 = Exbtn4;
6877 int32_t up = DUbtn;
6878 int32_t down = DDbtn;
6879 int32_t left = DLbtn;
6880 int32_t right = DRbtn;
6881
6882 gamepad_dlg[0].dp2=lfont;
6883 if(analog_movement)
6884 gamepad_dlg[56].flags|=D_SELECTED;
6885 else
6886 gamepad_dlg[56].flags&=~D_SELECTED;
6887
6888 large_dialog(gamepad_dlg);
6889
6890 int32_t ret = zc_popup_dialog(gamepad_dlg,4);
6891
6892 if(ret == 4) //OK
6893 {
6894 analog_movement = gamepad_dlg[56].flags&D_SELECTED;
6895 save_control_configs(false);
6896 }
6897 else //Cancel
6898 {
6899 Abtn = a;
6900 Bbtn = b;
6901 Sbtn = s;
6902 Lbtn = l;
6903 Rbtn = r;
6904 Mbtn = m;
6905 Pbtn = p;
6906 Exbtn1 = ex1;
6907 Exbtn2 = ex2;
6908 Exbtn3 = ex3;
6909 Exbtn4 = ex4;
6910 DUbtn = up;
6911 DDbtn = down;
6912 DLbtn = left;
6913 DRbtn = right;
6914 }
6915
6916 return D_O_K;
6917 }
6918
6919 int32_t onCheatKeys()
6920 {
6921 int32_t oldcheats[Cheat::Last][2];
6922 memcpy(oldcheats, cheatkeys, sizeof(cheatkeys));
6923
6924 bool done=false;
6925
6926 while(!done)
6927 {
6928 bool confirm = false;
6929 CheatKeysDialog(&confirm).show();
6930 if(confirm) // OK
6931 {
6932 std::vector<std::string> uniqueError;
6933 char buf[512];
6934 for(size_t q = 1; q < Cheat::Last; ++q)
6935 {
6936 if(cheatkeys[q][1] && !cheatkeys[q][0])
6937 {
6938 cheatkeys[q][0] = cheatkeys[q][1];
6939 cheatkeys[q][1] = 0;
6940 }
6941 }
6942 for(size_t q = 1; q < Cheat::Last; ++q)
6943 {
6944 if(!bindable_cheat((Cheat)q)) continue;
6945 for(size_t p = q+1; p < Cheat::Last; ++p)
6946 {
6947 if(!bindable_cheat((Cheat)p)) continue;
6948 for(size_t q2 = 0; q2 <= 1; ++q2)
6949 for(size_t p2 = 0; p2 <= 1; ++p2)
6950 {
6951 if(cheatkeys[q][q2] == cheatkeys[p][p2] && cheatkeys[q][q2] != 0)
6952 {
6953 uniqueError.push_back(fmt::format("'{}' ({}) conflicts with '{}' ({}) - both '{}'",
6954 cheat_to_string((Cheat)q), q2?"Alt":"Main",
6955 cheat_to_string((Cheat)p), p2?"Alt":"Main",
6956 get_keystr(cheatkeys[q][q2])));
6957 }
6958 }
6959 }
6960 }
6961 if(uniqueError.size() == 0)
6962 {
6963 done = true;
6964 save_cheatkeys();
6965 }
6966 else
6967 {
6968 box_start(1, "Duplicate Keys", lfont, sfont, false, 500,400, 2);
6969 box_out("Cannot have duplicate keybinds!"); box_eol();
6970 for(std::vector<std::string>::iterator it = uniqueError.begin();
6971 it != uniqueError.end(); ++it)
6972 {
6973 box_out((*it).c_str()); box_eol();
6974 }
6975 box_end(true);
6976 }
6977 }
6978 else // Cancel
6979 {
6980 memcpy(cheatkeys, oldcheats, sizeof(cheatkeys));
6981 done=true;
6982 }
6983 rest(1);
6984 }
6985
6986 return D_O_K;
6987 }
6988
6989 int32_t onSound()
6990 {
6991 if ( FFCore.coreflags&FFCORE_SCRIPTED_MIDI_VOLUME )
6992 {
6993 master_volume(-1,((int32_t)FFCore.usr_midi_volume));
6994 }
6995 if ( FFCore.coreflags&FFCORE_SCRIPTED_DIGI_VOLUME )
6996 {
6997 master_volume((int32_t)(FFCore.usr_digi_volume),1);
6998 }
6999 if ( FFCore.coreflags&FFCORE_SCRIPTED_MUSIC_VOLUME )
7000 {
7001 emusic_volume = (int32_t)FFCore.usr_music_volume;
7002 }
7003 if ( FFCore.coreflags&FFCORE_SCRIPTED_SFX_VOLUME )
7004 {
7005 sfx_volume = (int32_t)FFCore.usr_sfx_volume;
7006 }
7007 if ( FFCore.coreflags&FFCORE_SCRIPTED_PANSTYLE )
7008 {
7009 pan_style = (int32_t)FFCore.usr_panstyle;
7010 }
7011
7012 int32_t m = midi_volume;
7013 int32_t d = digi_volume;
7014 int32_t e = emusic_volume;
7015 int32_t b = zcmusic_bufsz;
7016 int32_t s = sfx_volume;
7017 int32_t p = pan_style;
7018 pan_style = vbound(pan_style,0,3);
7019
7020 sound_dlg[0].dp2=lfont;
7021
7022 large_dialog(sound_dlg);
7023
7024 midi_dp[1] = sound_dlg[6].x;
7025 midi_dp[2] = sound_dlg[6].y;
7026 digi_dp[1] = sound_dlg[7].x;
7027 digi_dp[2] = sound_dlg[7].y;
7028 emus_dp[1] = sound_dlg[8].x;
7029 emus_dp[2] = sound_dlg[8].y;
7030 buf_dp[1] = sound_dlg[9].x;
7031 buf_dp[2] = sound_dlg[9].y;
7032 sfx_dp[1] = sound_dlg[10].x;
7033 sfx_dp[2] = sound_dlg[10].y;
7034 pan_dp[1] = sound_dlg[11].x;
7035 pan_dp[2] = sound_dlg[11].y;
7036 sound_dlg[15].d2 = (midi_volume==255) ? 32 : midi_volume>>3;
7037 sound_dlg[16].d2 = (digi_volume==255) ? 32 : digi_volume>>3;
7038 sound_dlg[17].d2 = (emusic_volume==255) ? 32 : emusic_volume>>3;
7039 sound_dlg[18].d2 = zcmusic_bufsz;
7040 sound_dlg[19].d2 = (sfx_volume==255) ? 32 : sfx_volume>>3;
7041 sound_dlg[20].d2 = pan_style;
7042
7043 int32_t ret = zc_popup_dialog(sound_dlg,1);
7044
7045 if(ret==2)
7046 {
7047 master_volume(digi_volume,midi_volume);
7048
7049 for(int32_t i=0; i<WAV_COUNT; ++i)
7050 {
7051 //allegro assertion fails when passing in -1 as voice -DD
7052 if(sfx_voice[i] > 0)
7053 voice_set_volume(sfx_voice[i], sfx_volume);
7054 }
7055 zc_set_config(sfx_sect,"digi",digi_volume);
7056 zc_set_config(sfx_sect,"midi",midi_volume);
7057 zc_set_config(sfx_sect,"sfx",sfx_volume);
7058 zc_set_config(sfx_sect,"emusic",emusic_volume);
7059 zc_set_config(sfx_sect,"pan",pan_style);
7060 zc_set_config(sfx_sect,"zcmusic_bufsz",zcmusic_bufsz);
7061 }
7062 else
7063 {
7064 midi_volume = m;
7065 digi_volume = d;
7066 emusic_volume = e;
7067 zcmusic_bufsz = b;
7068 sfx_volume = s;
7069 pan_style = p;
7070 }
7071
7072 return D_O_K;
7073 }
7074
7075 int32_t queding(char const* s1, char const* s2, char const* s3)
7076 {
7077 return jwin_alert(ZC_str,s1,s2,s3,"&Yes","&No",'y','n',lfont);
7078 }
7079
7080 int32_t onQuit()
7081 {
7082 if(Playing)
7083 {
7084 int32_t ret=0;
7085
7086 if(get_bit(quest_rules, qr_NOCONTINUE))
7087 {
7088 if(standalone_mode)
7089 {
7090 ret=queding("End current game?",
7091 "The continue screen is disabled; the game",
7092 "will be reloaded from the last save.");
7093 }
7094 else
7095 {
7096 ret=queding("End current game?",
7097 "The continue screen is disabled. You will",
7098 "be returned to the file select screen.");
7099 }
7100 }
7101 else
7102 ret=queding("End current game?",NULL,NULL);
7103
7104 if(ret==1)
7105 {
7106 disableClickToFreeze=false;
7107 Quit=qQUIT;
7108
7109 // Trying to evade a door repair charge?
7110 if(repaircharge)
7111 {
7112 game->change_drupy(-repaircharge);
7113 repaircharge=0;
7114 }
7115
7116 return D_CLOSE;
7117 }
7118 }
7119
7120 return D_O_K;
7121 }
7122
7123 int32_t onTryQuitMenu()
7124 {
7125 return onTryQuit(true);
7126 }
7127
7128 int32_t onTryQuit(bool inMenu)
7129 {
7130 if(Playing && !(GameFlags & GAMEFLAG_NO_F6))
7131 {
7132 if(get_bit(quest_rules,qr_OLD_F6))
7133 {
7134 if(inMenu) onQuit();
7135 else /*if(!get_bit(quest_rules, qr_NOCONTINUE))*/ f_Quit(qQUIT);
7136 }
7137 else
7138 {
7139 disableClickToFreeze=false;
7140 GameFlags |= GAMEFLAG_TRYQUIT;
7141 }
7142 return D_CLOSE;
7143 }
7144
7145 return D_O_K;
7146 }
7147
7148 int32_t onReset()
7149 {
7150 if(queding(" Reset system? ",NULL,NULL)==1)
7151 {
7152 disableClickToFreeze=false;
7153 Quit=qRESET;
7154 replay_quit();
7155 return D_CLOSE;
7156 }
7157
7158 return D_O_K;
7159 }
7160
7161 int32_t onExit()
7162 {
7163 if(queding(" Quit Zelda Classic? ",NULL,NULL)==1)
7164 {
7165 Quit=qEXIT;
7166 return D_CLOSE;
7167 }
7168
7169 return D_O_K;
7170 }
7171
7172 int32_t onTitle_NES()
7173 {
7174 title_version=0;
7175 zc_set_config(cfg_sect,"title",title_version);
7176 return D_O_K;
7177 }
7178 int32_t onTitle_DX()
7179 {
7180 title_version=1;
7181 zc_set_config(cfg_sect,"title",title_version);
7182 return D_O_K;
7183 }
7184 int32_t onTitle_25()
7185 {
7186 title_version=2;
7187 zc_set_config(cfg_sect,"title",title_version);
7188 return D_O_K;
7189 }
7190
7191 int32_t onDebug()
7192 {
7193 if(debug_enabled)
7194 set_debug(!get_debug());
7195 return D_O_K;
7196 }
7197
7198 int32_t onHeartBeep()
7199 {
7200 heart_beep=!heart_beep;
7201 zc_set_config(cfg_sect,"heart_beep",heart_beep);
7202 return D_O_K;
7203 }
7204
7205 int32_t onSaveIndicator()
7206 {
7207 use_save_indicator=!use_save_indicator;
7208 zc_set_config(cfg_sect,"save_indicator",use_save_indicator);
7209 return D_O_K;
7210 }
7211
7212 int32_t onEpilepsy()
7213 {
7214 if(jwin_alert3(
7215 "Epilepsy Flash Reduction",
7216 "Enabling this will reduce the intensity of flashing and screen wave effects.",
7217 "Disabling this will restore standard flash and wavy behaviour.",
7218 "Proceed?",
7219 "&Yes",
7220 "&No",
7221 NULL,
7222 'y',
7223 'n',
7224 0,
7225 lfont) == 1)
7226 {
7227 epilepsyFlashReduction = epilepsyFlashReduction ? 0 : 1;
7228 zc_set_config("zeldadx","checked_epilepsy",1);
7229 zc_set_config(cfg_sect,"epilepsy_flash_reduction",epilepsyFlashReduction);
7230 }
7231 return D_O_K;
7232 }
7233
7234 int32_t onTriforce()
7235 {
7236 for(int32_t i=0; i<MAXINITTABS; ++i)
7237 {
7238 init_tabs[i].flags&=~D_SELECTED;
7239 }
7240
7241 init_tabs[3].flags=D_SELECTED;
7242 return onCheatConsole();
7243 /*triforce_dlg[0].dp2=lfont;
7244 for(int32_t i=1; i<=8; i++)
7245 triforce_dlg[i].flags = (game->lvlitems[i] & liTRIFORCE) ? D_SELECTED : 0;
7246
7247 if(zc_popup_dialog (triforce_dlg,-1)==9)
7248 {
7249 for(int32_t i=1; i<=8; i++)
7250 {
7251 game->lvlitems[i] &= ~liTRIFORCE;
7252 game->lvlitems[i] |= (triforce_dlg[i].flags & D_SELECTED) ? liTRIFORCE : 0;
7253 }
7254 }
7255 return D_O_K;*/
7256 }
7257
7258 bool rc = false;
7259 /*
7260 int32_t onEquipment()
7261 {
7262 for (int32_t i=0; i<MAXINITTABS; ++i)
7263 {
7264 init_tabs[i].flags&=~D_SELECTED;
7265 }
7266 init_tabs[0].flags=D_SELECTED;
7267 return onCheatConsole();
7268 }
7269 */
7270
7271 int32_t onItems()
7272 {
7273 for(int32_t i=0; i<MAXINITTABS; ++i)
7274 {
7275 init_tabs[i].flags&=~D_SELECTED;
7276 }
7277
7278 init_tabs[1].flags=D_SELECTED;
7279 return onCheatConsole();
7280 }
7281
7282 static DIALOG getnum_dlg[] =
7283 {
7284 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
7285 { jwin_win_proc, 80, 80, 160, 72, vc(0), vc(11), 0, D_EXIT, 0, 0, NULL, NULL, NULL },
7286 { jwin_text_proc, 104, 104+4, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Number:", NULL, NULL },
7287 { jwin_edit_proc, 168, 104, 48, 16, 0, 0, 0, 0, 6, 0, NULL, NULL, NULL },
7288 { jwin_button_proc, 90, 126, 61, 21, vc(0), vc(11), 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
7289 { jwin_button_proc, 170, 126, 61, 21, vc(0), vc(11), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
7290 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
7291 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
7292 };
7293
7294 int32_t getnumber(const char *prompt,int32_t initialval)
7295 {
7296 char buf[20];
7297 sprintf(buf,"%d",initialval);
7298 getnum_dlg[0].dp=(void *)prompt;
7299 getnum_dlg[0].dp2=lfont;
7300 getnum_dlg[2].dp=buf;
7301
7302 large_dialog(getnum_dlg);
7303
7304 if(zc_popup_dialog(getnum_dlg,2)==3)
7305 return atoi(buf);
7306
7307 return initialval;
7308 }
7309
7310 int32_t onLife()
7311 {
7312 int value = vbound(getnumber("Life",game->get_life()),1,game->get_maxlife());
7313 cheats_enqueue(Cheat::Life, value);
7314 return D_O_K;
7315 }
7316
7317 int32_t onHeartC()
7318 {
7319 int max_life = vbound(getnumber("Heart Containers",game->get_maxlife()/game->get_hp_per_heart()),1,4095) * game->get_hp_per_heart();
7320 int life = vbound(getnumber("Life",game->get_life()/game->get_hp_per_heart()),1,max_life/game->get_hp_per_heart())*game->get_hp_per_heart();
7321 cheats_enqueue(Cheat::MaxLife, max_life);
7322 cheats_enqueue(Cheat::Life, life);
7323 return D_O_K;
7324 }
7325
7326 int32_t onMagicC()
7327 {
7328 int max_magic = vbound(getnumber("Magic Containers",game->get_maxmagic()/game->get_mp_per_block()),0,2047) * game->get_mp_per_block();
7329 int magic = vbound(getnumber("Magic",game->get_magic()/game->get_mp_per_block()),0,game->get_maxmagic()/game->get_mp_per_block())*game->get_mp_per_block();
7330 cheats_enqueue(Cheat::MaxMagic, max_magic);
7331 cheats_enqueue(Cheat::Magic, magic);
7332 return D_O_K;
7333 }
7334
7335 int32_t onRupies()
7336 {
7337 int value = vbound(getnumber("Rupees",game->get_rupies()),0,game->get_maxcounter(1));
7338 cheats_enqueue(Cheat::Rupies, value);
7339 return D_O_K;
7340 }
7341
7342 int32_t onMaxBombs()
7343 {
7344 int value = vbound(getnumber("Max Bombs",game->get_maxbombs()),0,0xFFFF);
7345 cheats_enqueue(Cheat::MaxBombs, value);
7346 cheats_enqueue(Cheat::Bombs, value);
7347 return D_O_K;
7348 }
7349
7350 int32_t onRefillLife()
7351 {
7352 cheats_enqueue(Cheat::Life, game->get_maxlife());
7353 return D_O_K;
7354 }
7355 int32_t onRefillMagic()
7356 {
7357 cheats_enqueue(Cheat::Magic, game->get_maxmagic());
7358 return D_O_K;
7359 }
7360 int32_t onClock()
7361 {
7362 cheats_enqueue(Cheat::Clock);
7363 return D_O_K;
7364 }
7365
7366 int32_t onQstPath()
7367 {
7368 char path[2048];
7369
7370 chop_path(qstdir);
7371 strcpy(path,qstdir);
7372
7373 go();
7374
7375 if(jwin_dfile_select_ex("Quest File Directory", path, "qst", 2048, -1, -1, lfont))
7376 {
7377 chop_path(path);
7378 fix_filename_case(path);
7379 fix_filename_slashes(path);
7380 strcpy(qstdir,path);
7381 strcpy(qstpath,qstdir);
7382 }
7383
7384 comeback();
7385 return D_O_K;
7386 }
7387
7388 #include "dialog/cheat_dialog.h"
7389 int32_t onCheat()
7390 {
7391 call_setcheat_dialog();
7392 game->set_cheat(maxcheat);
7393 if(cheat) game->did_cheat(true);
7394 return D_O_K;
7395 }
7396
7397 int32_t onCheatRupies()
7398 {
7399 cheats_enqueue(Cheat::Rupies, game->get_maxcounter(1));
7400 return D_O_K;
7401 }
7402
7403 int32_t onCheatArrows()
7404 {
7405 cheats_enqueue(Cheat::Arrows, game->get_maxarrows());
7406 return D_O_K;
7407 }
7408
7409 int32_t onCheatBombs()
7410 {
7411 cheats_enqueue(Cheat::Bombs, game->get_maxbombs(), game->get_maxcounter(6));
7412 return D_O_K;
7413 }
7414
7415 // *** screen saver
7416
7417 6510614 int32_t after_time()
7418 {
7419
1/2
✓ Branch 0 taken 6510614 times.
✗ Branch 1 not taken.
6510614 if(ss_enable == 0)
7420 return INT_MAX;
7421
7422
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6510614 times.
6510614 if(ss_after <= 0)
7423 return 5 * 60;
7424
7425
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6510614 times.
6510614 if(ss_after <= 3)
7426 return ss_after * 15 * 60;
7427
7428
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6510614 times.
6510614 if(ss_after <= 13)
7429 return (ss_after - 3) * 60 * 60;
7430
7431 6510614 return MAX_IDLE + 1;
7432 6510614 }
7433
7434 static const char *after_str[15] =
7435 {
7436 " 5 sec", "15 sec", "30 sec", "45 sec", " 1 min", " 2 min", " 3 min",
7437 " 4 min", " 5 min", " 6 min", " 7 min", " 8 min", " 9 min", "10 min",
7438 "Never"
7439 };
7440
7441 const char *after_list(int32_t index, int32_t *list_size)
7442 {
7443 if(index < 0)
7444 {
7445 *list_size = 15;
7446 return NULL;
7447 }
7448
7449 return after_str[index];
7450 }
7451
7452 29 static ListData after__list(after_list, &font, &a5font);
7453
7454 static DIALOG scrsaver_dlg[] =
7455 {
7456 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
7457 29 { jwin_win_proc, 32, 64, 256, 136, 0, 0, 0, D_EXIT, 0, 0, (void *) "Screen Saver Settings", NULL, NULL },
7458 29 { jwin_frame_proc, 42, 92, 236, 70, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
7459 29 { jwin_text_proc, 60, 104, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Run After", NULL, NULL },
7460 29 { jwin_text_proc, 60, 128, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Speed", NULL, NULL },
7461 29 { jwin_text_proc, 60, 144, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Density", NULL, NULL },
7462 29 { jwin_droplist_proc, 144, 100, 96, 16, 0, 0, 0, 0, 0, 0, (void *) &after__list, NULL, NULL },
7463 29 { jwin_slider_proc, 144, 128, 116, 8, vc(0), jwin_pal[jcBOX], 0, 0, 6, 0, NULL, NULL, NULL },
7464 29 { jwin_slider_proc, 144, 144, 116, 8, vc(0), jwin_pal[jcBOX], 0, 0, 6, 0, NULL, NULL, NULL },
7465 29 { jwin_button_proc, 42, 170, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
7466 29 { jwin_button_proc, 124, 170, 72, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Preview", NULL, NULL },
7467 29 { jwin_button_proc, 218, 170, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
7468 29 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
7469 29 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
7470 };
7471
7472 int32_t onScreenSaver()
7473 {
7474 scrsaver_dlg[0].dp2=lfont;
7475 int32_t oldcfgs[3];
7476 scrsaver_dlg[5].d1 = scrsaver_dlg[5].d2 = oldcfgs[0] = ss_after;
7477 scrsaver_dlg[6].d2 = oldcfgs[1] = ss_speed;
7478 scrsaver_dlg[7].d2 = oldcfgs[2] = ss_density;
7479
7480 large_dialog(scrsaver_dlg);
7481
7482 int32_t ret = zc_popup_dialog(scrsaver_dlg,-1);
7483
7484 if(ret == 8 || ret == 9)
7485 {
7486 ss_after = scrsaver_dlg[5].d1;
7487 ss_speed = scrsaver_dlg[6].d2;
7488 ss_density = scrsaver_dlg[7].d2;
7489 if(oldcfgs[0] != ss_after)
7490 zc_set_config(cfg_sect,"ss_after",ss_after);
7491 if(oldcfgs[1] != ss_speed)
7492 zc_set_config(cfg_sect,"ss_speed",ss_speed);
7493 if(oldcfgs[2] != ss_density)
7494 zc_set_config(cfg_sect,"ss_density",ss_density);
7495 }
7496
7497 if(ret == 9)
7498 // preview Screen Saver
7499 {
7500 clear_keybuf();
7501 scare_mouse();
7502 Matrix(ss_speed, ss_density, 30);
7503 system_pal();
7504 unscare_mouse();
7505 }
7506
7507 return D_O_K;
7508 }
7509
7510 /***** Menus *****/
7511
7512 static MENU game_menu[] =
7513 {
7514 { (char *)"&Continue\tESC", onContinue, NULL, 0, NULL },
7515 { (char *)"", NULL, NULL, 0, NULL },
7516 { (char *)"L&oad Quest...", onCustomGame, NULL, 0, NULL },
7517 { (char *)"&End Game\tF6", onTryQuitMenu, NULL, 0, NULL },
7518 { (char *)"", NULL, NULL, 0, NULL },
7519 #ifdef __EMSCRIPTEN__
7520 { (char *)"&Reset\tF7", onReset, NULL, 0, NULL },
7521 #elif defined(ALLEGRO_MACOSX)
7522 { (char *)"&Reset\tF7", onReset, NULL, 0, NULL },
7523 { (char *)"&Quit\tF8", onExit, NULL, 0, NULL },
7524 #else
7525 { (char *)"&Reset\tF9", onReset, NULL, 0, NULL },
7526 { (char *)"&Quit\tF10", onExit, NULL, 0, NULL },
7527 #endif
7528 { NULL, NULL, NULL, 0, NULL }
7529 };
7530
7531 static MENU title_menu[] =
7532 {
7533 { (char *)"&Original", onTitle_NES, NULL, 0, NULL },
7534 { (char *)"&Zelda Classic", onTitle_DX, NULL, 0, NULL },
7535 { (char *)"Zelda Classic &2.50", onTitle_25, NULL, 0, NULL },
7536 { NULL, NULL, NULL, 0, NULL }
7537 };
7538
7539 static MENU snapshot_format_menu[] =
7540 {
7541 { (char *)"&BMP", onSetSnapshotFormat, NULL, 0, NULL },
7542 { (char *)"&GIF", onSetSnapshotFormat, NULL, 0, NULL },
7543 { (char *)"&JPG", onSetSnapshotFormat, NULL, 0, NULL },
7544 { (char *)"&PNG", onSetSnapshotFormat, NULL, 0, NULL },
7545 { (char *)"PC&X", onSetSnapshotFormat, NULL, 0, NULL },
7546 { (char *)"&TGA", onSetSnapshotFormat, NULL, 0, NULL },
7547 { NULL, NULL, NULL, 0, NULL }
7548 };
7549
7550 static MENU controls_menu[] =
7551 {
7552 { (char *)"Key&board...", onKeyboard, NULL, 0, NULL },
7553 { (char *)"&Gamepad...", onGamepad, NULL, 0, NULL },
7554 { (char *)"&Cheat Keys...", onCheatKeys, NULL, 0, NULL },
7555 { NULL, NULL, NULL, 0, NULL }
7556 };
7557
7558 static MENU name_entry_mode_menu[] =
7559 {
7560 { (char *)"&Keyboard", onKeyboardEntry, NULL, 0, NULL },
7561 { (char *)"&Letter Grid", onLetterGridEntry, NULL, 0, NULL },
7562 { (char *)"&Extended Letter Grid", onExtLetterGridEntry, NULL, 0, NULL },
7563 { NULL, NULL, NULL, 0, NULL }
7564 };
7565
7566 static void set_controls_menu_active()
7567 {
7568
7569 }
7570
7571 static MENU settings_menu[] =
7572 {
7573 { (char *)"&Sound...", onSound, NULL, 0, NULL },
7574 { (char *)"C&ontrols", NULL, controls_menu, 0, NULL },
7575 { (char *)"&Title Screen", NULL, title_menu, 0, NULL },
7576 { (char *)"Name &Entry Mode", NULL, name_entry_mode_menu, 0, NULL },
7577 { (char *)"", NULL, NULL, 0, NULL },
7578 { (char *)"&Cap FPS\tF1", onVsync, NULL, 0, NULL },
7579 { (char *)"Show &FPS\tF2", onShowFPS, NULL, 0, NULL },
7580 { (char *)"Show Trans. &Layers", onTransLayers, NULL, 0, NULL },
7581 { (char *)"Up+A+B To &Quit", onNESquit, NULL, 0, NULL },
7582 { (char *)"Click to Freeze", onClickToFreeze, NULL, 0, NULL },
7583 { (char *)"Autosave Window Size Changes", onSaveDragResize, NULL, 0, NULL },
7584 { (char *)"Lock Aspect Ratio", onDragAspect, NULL, 0, NULL },
7585 { (char *)"Window Position Saving", onWinPosSave, NULL, 0, NULL },
7586 { (char *)"Volume &Keys", onVolKeys, NULL, 0, NULL },
7587 { (char *)"Cont. &Heart Beep", onHeartBeep, NULL, 0, NULL },
7588 { (char *)"Sa&ve Indicator", onSaveIndicator, NULL, 0, NULL },
7589 { (char *)"Epilepsy Flash Reduction", onEpilepsy, NULL, 0, NULL },
7590 { (char *)"S&napshot Format", NULL, snapshot_format_menu, 0, NULL },
7591 { (char *)"", NULL, NULL, 0, NULL },
7592 { (char *)"Debu&g", onDebug, NULL, 0, NULL },
7593 { (char *)"", NULL, NULL, 0, NULL },
7594 { NULL, NULL, NULL, 0, NULL }
7595 };
7596
7597
7598 static MENU misc_menu[] =
7599 {
7600 { (char *)"&About...", onAbout, NULL, 0, NULL },
7601 { (char *)"&Credits...", onCredits, NULL, 0, NULL },
7602 { (char *)"&Fullscreen", onFullscreenMenu, NULL, 0, NULL },
7603 { (char *)"&Video Mode...", onVidMode, NULL, 0, NULL },
7604 { (char *)"", NULL, NULL, 0, NULL },
7605 //5
7606 { (char *)"&Quest Info...", onQuest, NULL, 0, NULL },
7607 { (char *)"Quest &MIDI Info...", onMIDICredits, NULL, 0, NULL },
7608 { (char *)"Quest &Directory...", onQstPath, NULL, 0, NULL },
7609 { (char *)"", NULL, NULL, 0, NULL },
7610 { (char *)"Take &Snapshot\tF12", onSnapshot, NULL, 0, NULL },
7611 //10
7612 { (char *)"Sc&reen Saver...", onScreenSaver, NULL, 0, NULL },
7613 { (char *)"Save ZC Configuration", OnSaveZCConfig, NULL, 0, NULL },
7614 { (char *)"Show ZASM Debugger", onConsoleZASM, NULL, 0, NULL },
7615 { (char *)"Show ZScript Debugger", onConsoleZScript, NULL, 0, NULL },
7616 { (char *)"Clear Console on Qst Load", onClrConsoleOnLoad, NULL, 0, NULL },
7617 //15
7618 { (char *)"Clear Directory Cache", OnnClearQuestDir, NULL, 0, NULL },
7619 { (char *)"Modules", NULL, zcmodule_menu, 0, NULL },
7620 { (char *)"Replay", NULL, replay_menu, 0, NULL },
7621
7622 { NULL, NULL, NULL, 0, NULL }
7623 };
7624
7625 static MENU refill_menu[] =
7626 {
7627 { (char *)"&Life", onRefillLife, NULL, 0, NULL },
7628 { (char *)"&Magic", onRefillMagic, NULL, 0, NULL },
7629 { (char *)"&Bombs", onCheatBombs, NULL, 0, NULL },
7630 { (char *)"&Rupees", onCheatRupies, NULL, 0, NULL },
7631 { (char *)"&Arrows", onCheatArrows, NULL, 0, NULL },
7632 { NULL, NULL, NULL, 0, NULL }
7633 };
7634
7635 static MENU show_menu[] =
7636 {
7637 { (char *)"Combos", onShowLayer0, NULL, 0, NULL },
7638 { (char *)"Layer 1", onShowLayer1, NULL, 0, NULL },
7639 { (char *)"Layer 2", onShowLayer2, NULL, 0, NULL },
7640 { (char *)"Layer 3", onShowLayer3, NULL, 0, NULL },
7641 { (char *)"Layer 4", onShowLayer4, NULL, 0, NULL },
7642 { (char *)"Layer 5", onShowLayer5, NULL, 0, NULL },
7643 { (char *)"Layer 6", onShowLayer6, NULL, 0, NULL },
7644 { (char *)"Overhead Combos", onShowLayerO, NULL, 0, NULL },
7645 { (char *)"Push Blocks", onShowLayerP, NULL, 0, NULL },
7646 { (char *)"Freeform Combos", onShowLayerF, NULL, 0, NULL },
7647 { (char *)"Sprites", onShowLayerS, NULL, 0, NULL },
7648 { (char *)"", NULL, NULL, 0, NULL },
7649 { (char *)"Current FFC Scripts", onShowFFScripts, NULL, 0, NULL },
7650 { (char *)"", NULL, NULL, 0, NULL },
7651 { (char *)"Walkability", onShowLayerW, NULL, 0, NULL },
7652 { (char *)"Hitboxes", onShowHitboxes, NULL, 0, NULL },
7653 { (char *)"Effects", onShowLayerE, NULL, 0, NULL },
7654 { (char *)"Info Opacity", onShowInfoOpacity, NULL, 0, NULL },
7655 { NULL, NULL, NULL, 0, NULL }
7656 };
7657
7658 static MENU cheat_menu[] =
7659 {
7660 { (char *)"Set &Cheat", onCheat, NULL, 0, NULL },
7661 { (char *)"", NULL, NULL, 0, NULL },
7662 { (char *)"Re&fill", NULL, refill_menu, 0, NULL },
7663 { (char *)"", NULL, NULL, 0, NULL },
7664 { (char *)"&Invincible", onClock, NULL, 0, NULL },
7665 { (char *)"Ma&x Bombs...", onMaxBombs, NULL, 0, NULL },
7666 { (char *)"&Heart Containers...", onHeartC, NULL, 0, NULL },
7667 { (char *)"&Magic Containers...", onMagicC, NULL, 0, NULL },
7668 { (char *)"", NULL, NULL, 0, NULL },
7669 { (char *)"&Player Data...", onCheatConsole, NULL, 0, NULL },
7670 { (char *)"", NULL, NULL, 0, NULL },
7671 { (char *)"Walk Through &Walls", onNoWalls, NULL, 0, NULL },
7672 { (char *)"Player Ignores Side&view", onIgnoreSideview, NULL, 0, NULL },
7673 { (char *)"&Quick Movement", onGoFast, NULL, 0, NULL },
7674 { (char *)"&Kill All Enemies", onKillCheat, NULL, 0, NULL },
7675 { (char *)"Trigger &Secrets", onSecretsCheat, NULL, 0, NULL },
7676 { (char *)"Trigger Secrets Perm", onSecretsCheatPerm, NULL, 0, NULL },
7677 { (char *)"Show/Hide Layer", NULL, show_menu, 0, NULL },
7678 { (char *)"Toggle &Light", onLightSwitch, NULL, 0, NULL },
7679 { (char *)"&Goto Location...", onGoTo, NULL, 0, NULL },
7680 { NULL, NULL, NULL, 0, NULL }
7681 };
7682
7683 static MENU fixes_menu[] =
7684 {
7685 { (char *)"Windows MIDI Patch", onMIDIPatch, NULL, 0, NULL },
7686 { NULL, NULL, NULL, 0, NULL }
7687 };
7688
7689 #if DEVLEVEL > 0
7690 int32_t devLogging();
7691 int32_t devDebug();
7692 int32_t devTimestmp();
7693 #if DEVLEVEL > 1
7694 int32_t setCheat();
7695 #endif //DEVLEVEL > 1
7696 enum
7697 {
7698 dv_log,
7699 // dv_dbg,
7700 dv_tmpstmp,
7701 #if DEVLEVEL > 1
7702 dv_nil,
7703 dv_setcheat,
7704 #endif //DEVLEVEL > 1
7705 dv_max
7706 };
7707 static MENU dev_menu[] =
7708 {
7709 { (char *)"&Force Error Log", devLogging, NULL, 0, NULL },
7710 // { (char *)"&Extra Debug Log", devDebug, NULL, 0, NULL },
7711 { (char *)"&Timestamp Log", devTimestmp, NULL, 0, NULL },
7712 #if DEVLEVEL > 1
7713 { (char *)"", NULL, NULL, 0, NULL },
7714 { (char *)"Set &Cheat", setCheat, NULL, 0, NULL },
7715 #endif //DEVLEVEL > 1
7716 { NULL, NULL, NULL, 0, NULL }
7717 };
7718 int32_t devLogging()
7719 {
7720 dev_logging = !dev_logging;
7721 dev_menu[dv_log].flags = dev_logging ? D_SELECTED : 0;
7722 return D_O_K;
7723 }
7724 // int32_t devDebug()
7725 // {
7726 // dev_debug = !dev_debug;
7727 // dev_menu[dv_dbg].flags = dev_debug ? D_SELECTED : 0;
7728 // return D_O_K;
7729 // }
7730 int32_t devTimestmp()
7731 {
7732 dev_timestmp = !dev_timestmp;
7733 dev_menu[dv_tmpstmp].flags = dev_timestmp ? D_SELECTED : 0;
7734 return D_O_K;
7735 }
7736 #if DEVLEVEL > 1
7737 int32_t setCheat()
7738 {
7739 cheat = (vbound(getnumber("Cheat Level",cheat), 0, 4));
7740 return D_O_K;
7741 }
7742 #endif //DEVLEVEL > 1
7743 #endif //DEVLEVEL > 0
7744
7745 MENU the_player_menu[] =
7746 {
7747 { (char *)"&Game", NULL, game_menu, 0, NULL },
7748 { (char *)"&Settings", NULL, settings_menu, 0, NULL },
7749 { (char *)"&Cheat", NULL, cheat_menu, 0, NULL },
7750 { (char *)"&Fixes", NULL, fixes_menu, 0, NULL },
7751 { (char *)"&ZC", NULL, misc_menu, 0, NULL },
7752 #if DEVLEVEL > 0
7753 { (char *)"&Dev", NULL, dev_menu, 0, NULL },
7754 #endif
7755 { NULL, NULL, NULL, 0, NULL }
7756 };
7757
7758 MENU the_player_menu2[] =
7759 {
7760 { (char *)"&Game", NULL, game_menu, 0, NULL },
7761 { (char *)"&Settings", NULL, settings_menu, 0, NULL },
7762 { (char *)"&Fixes", NULL, fixes_menu, 0, NULL },
7763 { (char *)"&ZC", NULL, misc_menu, 0, NULL },
7764 #if DEVLEVEL > 0
7765 { (char *)"&Dev", NULL, dev_menu, 0, NULL },
7766 #endif
7767 { NULL, NULL, NULL, 0, NULL }
7768 };
7769
7770 int32_t onMIDIPatch()
7771 {
7772 if(jwin_alert3(
7773 "Toggle Windows MIDI Fix",
7774 "This action will change whether ZC Player auto-restarts a MIDI at its",
7775 "last index if you move ZC Player out of focus, then back into focus.",
7776 "Proceed?",
7777 "&Yes",
7778 "&No",
7779 NULL,
7780 'y',
7781 'n',
7782 0,
7783 lfont) == 1)
7784 {
7785 midi_patch_fix = midi_patch_fix ? 0 : 1;
7786 zc_set_config("zeldadx","midi_patch_fix",midi_patch_fix);
7787 }
7788 fixes_menu[0].flags =(midi_patch_fix)?D_SELECTED:0;
7789 return D_O_K;
7790 }
7791
7792 int32_t onKeyboardEntry()
7793 {
7794 NameEntryMode=0;
7795 zc_set_config(cfg_sect,"name_entry_mode",NameEntryMode);
7796 return D_O_K;
7797 }
7798
7799 int32_t onLetterGridEntry()
7800 {
7801 NameEntryMode=1;
7802 zc_set_config(cfg_sect,"name_entry_mode",NameEntryMode);
7803 return D_O_K;
7804 }
7805
7806 int32_t onExtLetterGridEntry()
7807 {
7808 NameEntryMode=2;
7809 zc_set_config(cfg_sect,"name_entry_mode",NameEntryMode);
7810 return D_O_K;
7811 }
7812
7813 static BITMAP* oldscreen;
7814 int32_t onFullscreenMenu()
7815 {
7816 // super hacks
7817 screen = oldscreen;
7818 if (onFullscreen() == D_REDRAW)
7819 {
7820 oldscreen = screen;
7821 }
7822 screen = menu_bmp;
7823 misc_menu[2].flags =(isFullScreen()==1)?D_SELECTED:0;
7824 return D_O_K;
7825 }
7826
7827 29 void fix_menu()
7828 {
7829
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29 times.
29 if(!debug_enabled)
7830 29 settings_menu[18].text = NULL;
7831 29 }
7832
7833 static DIALOG system_dlg[] =
7834 {
7835 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
7836 { jwin_menu_proc, 0, 0, 0, 0, 0, 0, 0, D_USER, 0, 0, (void *) the_player_menu, NULL, NULL },
7837 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F1, 0, (void *) onVsync, NULL, NULL },
7838 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F2, 0, (void *) onShowFPS, NULL, NULL },
7839 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F6, 0, (void *) onTryQuitMenu, NULL, NULL },
7840 #ifndef ALLEGRO_MACOSX
7841 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F9, 0, (void *) onReset, NULL, NULL },
7842 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F10, 0, (void *) onExit, NULL, NULL },
7843 #else
7844 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F7, 0, (void *) onReset, NULL, NULL },
7845 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F8, 0, (void *) onExit, NULL, NULL },
7846 #endif
7847 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F12, 0, (void *) onSnapshot, NULL, NULL },
7848 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_TAB, 0, (void *) onDebug, NULL, NULL },
7849 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
7850 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
7851 };
7852
7853 static DIALOG system_dlg2[] =
7854 {
7855 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
7856 { jwin_menu_proc, 0, 0, 0, 0, 0, 0, 0, D_USER, 0, 0, (void *) the_player_menu2, NULL, NULL },
7857 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F1, 0, (void *) onVsync, NULL, NULL },
7858 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F2, 0, (void *) onShowFPS, NULL, NULL },
7859 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F6, 0, (void *) onTryQuitMenu, NULL, NULL },
7860 #ifndef ALLEGRO_MACOSX
7861 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F9, 0, (void *) onReset, NULL, NULL },
7862 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F10, 0, (void *) onExit, NULL, NULL },
7863 #else
7864 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F7, 0, (void *) onReset, NULL, NULL },
7865 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F8, 0, (void *) onExit, NULL, NULL },
7866 #endif
7867 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F12, 0, (void *) onSnapshot, NULL, NULL },
7868 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_TAB, 0, (void *) onDebug, NULL, NULL },
7869 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
7870 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
7871 };
7872
7873 void reset_snapshot_format_menu()
7874 {
7875 for(int32_t i=0; i<ssfmtMAX; ++i)
7876 {
7877 snapshot_format_menu[i].flags=0;
7878 }
7879 }
7880
7881 int32_t onSetSnapshotFormat()
7882 {
7883 switch(active_menu->text[1])
7884 {
7885 case 'B': //"&BMP"
7886 SnapshotFormat=0;
7887 break;
7888
7889 case 'G': //"&GIF"
7890 SnapshotFormat=1;
7891 break;
7892
7893 case 'J': //"&JPG"
7894 SnapshotFormat=2;
7895 break;
7896
7897 case 'P': //"&PNG"
7898 SnapshotFormat=3;
7899 break;
7900
7901 case 'C': //"PC&X"
7902 SnapshotFormat=4;
7903 break;
7904
7905 case 'T': //"&TGA"
7906 SnapshotFormat=5;
7907 break;
7908
7909 case 'L': //"&LBM"
7910 SnapshotFormat=6;
7911 break;
7912 }
7913 zc_set_config("zeldadx", "snapshot_format", SnapshotFormat);
7914
7915 snapshot_format_menu[SnapshotFormat].flags=D_SELECTED;
7916 return D_O_K;
7917 }
7918
7919
7920 43 void color_layer(RGB *src,RGB *dest,char r,char g,char b,char pos,int32_t from,int32_t to)
7921 {
7922 PALETTE tmp;
7923
7924
2/2
✓ Branch 0 taken 11008 times.
✓ Branch 1 taken 43 times.
11051 for(int32_t i=0; i<256; i++)
7925 {
7926 11008 tmp[i].r=r;
7927 11008 tmp[i].g=g;
7928 11008 tmp[i].b=b;
7929 11008 }
7930
7931 43 fade_interpolate(src,tmp,dest,pos,from,to);
7932 43 }
7933
7934 43 void system_pal()
7935 {
7936 43 is_sys_pal = true;
7937 static PALETTE pal;
7938 43 copy_pal((RGB*)datafile[PAL_GUI].dat, pal);
7939
7940 // set up the grayscale palette
7941
2/2
✓ Branch 0 taken 2752 times.
✓ Branch 1 taken 43 times.
2795 for(int32_t i=128; i<192; i++)
7942 {
7943 2752 pal[i].r = i-128;
7944 2752 pal[i].g = i-128;
7945 2752 pal[i].b = i-128;
7946 2752 }
7947 43 load_colorset(gui_colorset, pal);
7948
7949 43 color_layer(pal, pal, 24,16,16, 28, 128,191);
7950
7951
2/2
✓ Branch 0 taken 5504 times.
✓ Branch 1 taken 43 times.
5547 for(int32_t i=0; i<256; i+=2)
7952 {
7953 5504 int32_t v = (i>>3)+2;
7954 5504 int32_t c = (i>>3)+192;
7955 5504 pal[c] = _RGB(v,v,v+(v>>1));
7956 /*
7957 if(i<240)
7958 {
7959 _allegro_hline(tmp_scr,0,i,319,c);
7960 _allegro_hline(tmp_scr,0,i+1,319,c);
7961 }
7962 */
7963 5504 }
7964
7965 // draw the vertical screen gradient
7966
2/2
✓ Branch 0 taken 10320 times.
✓ Branch 1 taken 43 times.
10363 for(int32_t i=0; i<240; ++i)
7967 {
7968 10320 _allegro_hline(tmp_scr,0,i,319,192+(i*31/239));
7969 10320 }
7970
7971 /*
7972 palrstart= 10*63/255; palrend=166*63/255;
7973 palgstart= 36*63/255; palgend=202*63/255;
7974 palbstart=106*63/255; palbend=240*63/255;
7975 paldivs=32;
7976 for(int32_t i=0; i<paldivs; i++)
7977 {
7978 pal[223-paldivs+1+i].r = palrstart+((palrend-palrstart)*i/(paldivs-1));
7979 pal[223-paldivs+1+i].g = palgstart+((palgend-palgstart)*i/(paldivs-1));
7980 pal[223-paldivs+1+i].b = palbstart+((palbend-palbstart)*i/(paldivs-1));
7981 }
7982 */
7983 43 BITMAP *panorama = create_bitmap_ex(8,256,224);
7984 int32_t ts_height, ts_start;
7985
7986
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 43 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
43 if(tmpscr->flags3&fNOSUBSCR && !(tmpscr->flags3&fNOSUBSCROFFSET))
7987 {
7988 clear_to_color(panorama,0);
7989 blit(framebuf,panorama,0,playing_field_offset,0,28,256,224-passive_subscreen_height);
7990 ts_height=224-passive_subscreen_height;
7991 ts_start=28;
7992 }
7993 else
7994 {
7995 43 blit(framebuf,panorama,0,0,0,0,256,224);
7996 43 ts_height=224;
7997 43 ts_start=0;
7998 }
7999
8000 // gray scale the current frame
8001
2/2
✓ Branch 0 taken 9632 times.
✓ Branch 1 taken 43 times.
9675 for(int32_t y=0; y<ts_height; y++)
8002 {
8003
2/2
✓ Branch 0 taken 2465792 times.
✓ Branch 1 taken 9632 times.
2475424 for(int32_t x=0; x<256; x++)
8004 {
8005 2465792 int32_t c = panorama->line[y+ts_start][x];
8006
2/2
✓ Branch 0 taken 2459902 times.
✓ Branch 1 taken 5890 times.
2465792 int32_t gray = zc_min((RAMpal[c].r*42 + RAMpal[c].g*75 + RAMpal[c].b*14) >> 7, 63);
8007 2465792 tmp_scr->line[y+8+ts_start][x+32] = gray+128;
8008 2465792 }
8009 9632 }
8010
8011 43 destroy_bitmap(panorama);
8012
8013 // display everything
8014 43 vsync();
8015 43 hw_palette = &pal;
8016 43 update_hw_pal = true;
8017
8018 // sys_pal = pal;
8019 43 memcpy(sys_pal,pal,sizeof(pal));
8020 43 }
8021
8022 void system_pal2()
8023 {
8024 is_sys_pal = true;
8025 static PALETTE RAMpal2;
8026 copy_pal((RGB*)datafile[PAL_GUI].dat, RAMpal2);
8027
8028 /* Windows 2000 colors
8029 RAMpal2[dvc(1)] = _RGB( 0*63/255, 0*63/255, 0*63/255);
8030 RAMpal2[dvc(2)] = _RGB( 66*63/255, 65*63/255, 66*63/255);
8031 RAMpal2[dvc(3)] = _RGB(132*63/255, 130*63/255, 132*63/255);
8032 RAMpal2[dvc(4)] = _RGB(212*63/255, 208*63/255, 200*63/255);
8033 RAMpal2[dvc(5)] = _RGB(255*63/255, 255*63/255, 255*63/255);
8034 RAMpal2[dvc(6)] = _RGB(255*63/255, 255*63/255, 225*63/255);
8035 RAMpal2[dvc(7)] = _RGB(255*63/255, 225*63/255, 160*63/255);
8036 RAMpal2[dvc(8)] = _RGB( 0*63/255, 0*63/255, 80*63/255);
8037
8038 byte palrstart= 10*63/255, palrend=166*63/255,
8039 palgstart= 36*63/255, palgend=202*63/255,
8040 palbstart=106*63/255, palbend=240*63/255,
8041 paldivs=7;
8042 for(int32_t i=0; i<paldivs; i++)
8043 {
8044 RAMpal2[dvc(15-paldivs+1)+i].r = palrstart+((palrend-palrstart)*i/(paldivs-1));
8045 RAMpal2[dvc(15-paldivs+1)+i].g = palgstart+((palgend-palgstart)*i/(paldivs-1));
8046 RAMpal2[dvc(15-paldivs+1)+i].b = palbstart+((palbend-palbstart)*i/(paldivs-1));
8047 }
8048 */
8049
8050 /* Windows 98 colors
8051 RAMpal2[dvc(1)] = _RGB( 0*63/255, 0*63/255, 0*63/255);
8052 RAMpal2[dvc(2)] = _RGB(128*63/255, 128*63/255, 128*63/255);
8053 RAMpal2[dvc(3)] = _RGB(192*63/255, 192*63/255, 192*63/255);
8054 RAMpal2[dvc(4)] = _RGB(223*63/255, 223*63/255, 223*63/255);
8055 RAMpal2[dvc(5)] = _RGB(255*63/255, 255*63/255, 255*63/255);
8056 RAMpal2[dvc(6)] = _RGB(255*63/255, 255*63/255, 225*63/255);
8057 RAMpal2[dvc(7)] = _RGB(255*63/255, 225*63/255, 160*63/255);
8058 RAMpal2[dvc(8)] = _RGB( 0*63/255, 0*63/255, 80*63/255);
8059
8060 byte palrstart= 0*63/255, palrend=166*63/255,
8061 palgstart= 0*63/255, palgend=202*63/255,
8062 palbstart=128*63/255, palbend=240*63/255,
8063 paldivs=7;
8064 for(int32_t i=0; i<paldivs; i++)
8065 {
8066 RAMpal2[dvc(15-paldivs+1)+i].r = palrstart+((palrend-palrstart)*i/(paldivs-1));
8067 RAMpal2[dvc(15-paldivs+1)+i].g = palgstart+((palgend-palgstart)*i/(paldivs-1));
8068 RAMpal2[dvc(15-paldivs+1)+i].b = palbstart+((palbend-palbstart)*i/(paldivs-1));
8069 }
8070 */
8071
8072 /* Windows 99 colors
8073 RAMpal2[dvc(1)] = _RGB( 0*63/255, 0*63/255, 0*63/255);
8074 RAMpal2[dvc(2)] = _RGB( 64*63/255, 64*63/255, 64*63/255);
8075 RAMpal2[dvc(3)] = _RGB(128*63/255, 128*63/255, 128*63/255);
8076 RAMpal2[dvc(4)] = _RGB(192*63/255, 192*63/255, 192*63/255);
8077 RAMpal2[dvc(5)] = _RGB(223*63/255, 223*63/255, 223*63/255);
8078 RAMpal2[dvc(6)] = _RGB(255*63/255, 255*63/255, 255*63/255);
8079 RAMpal2[dvc(7)] = _RGB(255*63/255, 255*63/255, 225*63/255);
8080 RAMpal2[dvc(8)] = _RGB(255*63/255, 225*63/255, 160*63/255);
8081 RAMpal2[dvc(9)] = _RGB( 0*63/255, 0*63/255, 80*63/255);
8082
8083 byte palrstart= 0*63/255, palrend=166*63/255,
8084 palgstart= 0*63/255, palgend=202*63/255,
8085
8086 palbstart=128*63/255, palbend=240*63/255,
8087 paldivs=6;
8088 for(int32_t i=0; i<paldivs; i++)
8089 {
8090 RAMpal2[dvc(15-paldivs+1)+i].r = palrstart+((palrend-palrstart)*i/(paldivs-1));
8091 RAMpal2[dvc(15-paldivs+1)+i].g = palgstart+((palgend-palgstart)*i/(paldivs-1));
8092 RAMpal2[dvc(15-paldivs+1)+i].b = palbstart+((palbend-palbstart)*i/(paldivs-1));
8093 }
8094 */
8095
8096
8097
8098 RAMpal2[dvc(1)] = _RGB(0*63/255, 0*63/255, 0*63/255);
8099 RAMpal2[dvc(2)] = _RGB(64*63/255, 64*63/255, 64*63/255);
8100 RAMpal2[dvc(3)] = _RGB(128*63/255, 128*63/255, 128*63/255);
8101 RAMpal2[dvc(4)] = _RGB(192*63/255, 192*63/255, 192*63/255);
8102 RAMpal2[dvc(5)] = _RGB(223*63/255, 223*63/255, 223*63/255);
8103 RAMpal2[dvc(6)] = _RGB(255*63/255, 255*63/255, 255*63/255);
8104 RAMpal2[dvc(7)] = _RGB(255*63/255, 255*63/255, 225*63/255);
8105 RAMpal2[dvc(8)] = _RGB(255*63/255, 225*63/255, 160*63/255);
8106 RAMpal2[dvc(9)] = _RGB(0*63/255, 0*63/255, 80*63/255);
8107
8108 byte palrstart= 0*63/255, palrend=166*63/255,
8109 palgstart= 0*63/255, palgend=202*63/255,
8110 palbstart=128*63/255, palbend=240*63/255,
8111 paldivs=6;
8112
8113 for(int32_t i=0; i<paldivs; i++)
8114 {
8115 RAMpal2[dvc(15-paldivs+1)+i].r = palrstart+((palrend-palrstart)*i/(paldivs-1));
8116 RAMpal2[dvc(15-paldivs+1)+i].g = palgstart+((palgend-palgstart)*i/(paldivs-1));
8117 RAMpal2[dvc(15-paldivs+1)+i].b = palbstart+((palbend-palbstart)*i/(paldivs-1));
8118 }
8119
8120 gui_bg_color=jwin_pal[jcBOX];
8121 gui_fg_color=jwin_pal[jcBOXFG];
8122
8123 jwin_set_colors(jwin_pal);
8124
8125
8126 // set up the new palette
8127 for(int32_t i=128; i<192; i++)
8128 {
8129 RAMpal2[i].r = i-128;
8130 RAMpal2[i].g = i-128;
8131 RAMpal2[i].b = i-128;
8132 }
8133
8134 /*
8135 for(int32_t i=0; i<64; i++)
8136 {
8137 RAMpal2[128+i] = _RGB(i,i,i)1));
8138 }
8139 */
8140
8141 /*
8142
8143 pal[vc(1)] = _RGB(0x00,0x00,0x14);
8144 pal[vc(4)] = _RGB(0x36,0x36,0x36);
8145 pal[vc(6)] = _RGB(0x10,0x10,0x10);
8146 pal[vc(7)] = _RGB(0x20,0x20,0x20);
8147 pal[vc(9)] = _RGB(0x20,0x20,0x24);
8148 pal[vc(11)] = _RGB(0x30,0x30,0x30);
8149 pal[vc(14)] = _RGB(0x3F,0x38,0x28);
8150
8151 gui_fg_color=vc(14);
8152 gui_bg_color=vc(1);
8153
8154 jwin_set_colors(jwin_pal);
8155 */
8156
8157 // color_layer(RAMpal2, RAMpal2, 24,16,16, 28, 128,191);
8158
8159 // set up the colors for the vertical screen gradient
8160 for(int32_t i=0; i<256; i+=2)
8161 {
8162 int32_t v = (i>>3)+2;
8163 int32_t c = (i>>3)+192;
8164 RAMpal2[c] = _RGB(v,v,v+(v>>1));
8165
8166 /*
8167 if(i<240)
8168 {
8169 _allegro_hline(tmp_scr,0,i,319,c);
8170 _allegro_hline(tmp_scr,0,i+1,319,c);
8171 }
8172 */
8173 }
8174
8175 // hw_palette = &RAMpal;
8176 // update_hw_pal = true;
8177
8178 for(int32_t i=0; i<240; ++i)
8179 {
8180 _allegro_hline(tmp_scr,0,i,319,192+(i*31/239));
8181 }
8182
8183 /*
8184 byte palrstart= 10*63/255, palrend=166*63/255,
8185 palgstart= 36*63/255, palgend=202*63/255,
8186 palbstart=106*63/255, palbend=240*63/255,
8187 paldivs=32;
8188 for(int32_t i=0; i<paldivs; i++)
8189 {
8190 pal[223-paldivs+1+i].r = palrstart+((palrend-palrstart)*i/(paldivs-1));
8191 pal[223-paldivs+1+i].g = palgstart+((palgend-palgstart)*i/(paldivs-1));
8192 pal[223-paldivs+1+i].b = palbstart+((palbend-palbstart)*i/(paldivs-1));
8193 }
8194 */
8195 BITMAP *panorama = create_bitmap_ex(8,256,224);
8196 int32_t ts_height, ts_start;
8197
8198 if(tmpscr->flags3&fNOSUBSCR && !(tmpscr->flags3&fNOSUBSCROFFSET))
8199 {
8200 clear_to_color(panorama,0);
8201 blit(framebuf,panorama,0,playing_field_offset,0,28,256,224-passive_subscreen_height);
8202 ts_height=224-passive_subscreen_height;
8203 ts_start=28;
8204 }
8205 else
8206 {
8207 blit(framebuf,panorama,0,0,0,0,256,224);
8208 ts_height=224;
8209 ts_start=0;
8210 }
8211
8212 // gray scale the current frame
8213 for(int32_t y=0; y<ts_height; y++)
8214 {
8215 for(int32_t x=0; x<256; x++)
8216 {
8217 int32_t c = panorama->line[y+ts_start][x];
8218 int32_t gray = zc_min((RAMpal2[c].r*42 + RAMpal2[c].g*75 + RAMpal2[c].b*14) >> 7, 63);
8219 tmp_scr->line[y+8+ts_start][x+32] = gray+128;
8220 }
8221 }
8222
8223 destroy_bitmap(panorama);
8224
8225 // display everything
8226 vsync();
8227 hw_palette = &RAMpal2;
8228 update_hw_pal = true;
8229
8230 blit(tmp_scr,screen,0,0,scrx,scry,320,240);
8231
8232 // sys_pal = pal;
8233 memcpy(sys_pal,RAMpal2,sizeof(RAMpal2));
8234 }
8235
8236 static uint32_t entered_sys_pal = 0;
8237 14 void enter_sys_pal()
8238 {
8239
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(is_sys_pal)
8240 {
8241 if(entered_sys_pal)
8242 ++entered_sys_pal;
8243 return;
8244 }
8245 14 system_pal();
8246 14 ++entered_sys_pal;
8247 14 }
8248 14 void exit_sys_pal()
8249 {
8250
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(entered_sys_pal)
8251 {
8252
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
14 if(!--entered_sys_pal)
8253 {
8254 14 game_pal();
8255 14 }
8256 14 }
8257 14 }
8258
8259 void switch_out_callback()
8260 {
8261 if (pause_in_background)
8262 {
8263 callback_switchin = 3;
8264 return;
8265 }
8266
8267 #ifdef _WIN32
8268 if(midi_patch_fix==0 || currmidi==-1)
8269 return;
8270
8271
8272 paused_midi_pos = midi_pos;
8273 zc_stop_midi();
8274 midi_paused=true;
8275 midi_suspended = midissuspHALTED;
8276 #endif
8277 }
8278
8279 void switch_in_callback()
8280 {
8281 if(pause_in_background)
8282 {
8283 return;
8284 }
8285
8286 #ifdef _WIN32
8287 if(midi_patch_fix==0 || currmidi==-1)
8288 return;
8289
8290 else
8291 {
8292 callback_switchin = 1;
8293 midi_suspended = midissuspRESUME;
8294 }
8295 #endif
8296 }
8297
8298 257 void game_pal()
8299 {
8300 257 is_sys_pal = false;
8301 257 entered_sys_pal = 0;
8302 257 clear_to_color(screen,BLACK);
8303 257 hw_palette = &RAMpal;
8304 257 update_hw_pal = true;
8305 257 }
8306
8307 static char bar_str[] = "";
8308
8309 14 void music_pause()
8310 {
8311 //al_pause_duh(tmplayer);
8312 14 zcmusic_pause(zcmusic, ZCM_PAUSE);
8313 14 zc_midi_pause();
8314 14 midi_paused=true;
8315 14 }
8316
8317 void music_resume()
8318 {
8319 //al_resume_duh(tmplayer);
8320 zcmusic_pause(zcmusic, ZCM_RESUME);
8321 zc_midi_resume();
8322 midi_paused=false;
8323 }
8324
8325 5320 void music_stop()
8326 {
8327 //al_stop_duh(tmplayer);
8328 //unload_duh(tmusic);
8329 //tmusic=NULL;
8330 //tmplayer=NULL;
8331 5320 zcmusic_stop(zcmusic);
8332 5320 zcmusic_unload_file(zcmusic);
8333 5320 zc_stop_midi();
8334 5320 midi_paused=false;
8335 5320 currmidi=-1;
8336 5320 }
8337
8338 void System()
8339 {
8340 mouse_down=gui_mouse_b();
8341 music_pause();
8342 pause_all_sfx();
8343 MenuOpen = true;
8344 system_pal();
8345 // FONT *oldfont=font;
8346 // font=tfont;
8347
8348 misc_menu[2].flags =(isFullScreen()==1)?D_SELECTED:0;
8349 misc_menu[3].flags =(isFullScreen()==1)?D_DISABLED:0;
8350
8351 game_menu[2].flags = getsaveslot() > -1 ? 0 : D_DISABLED;
8352 #if DEVLEVEL > 1
8353 dev_menu[dv_setcheat].flags = Playing ? 0 : D_DISABLED;
8354 #endif
8355 game_menu[3].flags =
8356 misc_menu[5].flags = Playing ? 0 : D_DISABLED;
8357 misc_menu[7].flags = !Playing ? 0 : D_DISABLED;
8358 fixes_menu[0].flags = (midi_patch_fix)?D_SELECTED:0;
8359 clear_keybuf();
8360 show_mouse(screen);
8361
8362 DIALOG_PLAYER *p;
8363
8364 clear_bitmap(menu_bmp);
8365 oldscreen = screen;
8366 screen = menu_bmp;
8367
8368 if(!Playing || (!zcheats.flags && !get_debug() && DEVLEVEL < 2 && !zqtesting_mode))
8369 {
8370 p = init_dialog(system_dlg2,-1);
8371 }
8372 else
8373 {
8374 p = init_dialog(system_dlg,-1);
8375 }
8376
8377 // drop the menu on startup if menu button pressed
8378 if(joybtn(Mbtn)||zc_getrawkey(KEY_ESC))
8379 simulate_keypress(KEY_G << 8);
8380
8381 do
8382 {
8383 if(close_button_quit)
8384 {
8385 close_button_quit = false;
8386 f_Quit(qEXIT);
8387 if(Quit) break;
8388 }
8389 rest(17);
8390
8391 if(mouse_down && !gui_mouse_b())
8392 mouse_down=0;
8393
8394 title_menu[0].flags = (title_version==0) ? D_SELECTED : 0;
8395 title_menu[1].flags = (title_version==1) ? D_SELECTED : 0;
8396 title_menu[2].flags = (title_version==2) ? D_SELECTED : 0;
8397
8398 settings_menu[1].flags = replay_is_replaying() ? D_DISABLED : 0;
8399 settings_menu[5].flags = Throttlefps?D_SELECTED:0;
8400 settings_menu[6].flags = ShowFPS?D_SELECTED:0;
8401 settings_menu[7].flags = TransLayers?D_SELECTED:0;
8402 settings_menu[8].flags = NESquit?D_SELECTED:0;
8403 settings_menu[9].flags = ClickToFreeze?D_SELECTED:0;
8404 settings_menu[10].flags = SaveDragResize?D_SELECTED:0;
8405 settings_menu[11].flags = DragAspect?D_SELECTED:0;
8406 settings_menu[12].flags = SaveWinPos?D_SELECTED:0;
8407 settings_menu[13].flags = volkeys?D_SELECTED:0;
8408 //Epilepsy Prevention
8409 settings_menu[16].flags = (epilepsyFlashReduction) ? D_SELECTED : 0;
8410
8411 name_entry_mode_menu[0].flags = (NameEntryMode==0)?D_SELECTED:0;
8412 name_entry_mode_menu[1].flags = (NameEntryMode==1)?D_SELECTED:0;
8413 name_entry_mode_menu[2].flags = (NameEntryMode==2)?D_SELECTED:0;
8414
8415 misc_menu[12].flags =(zasm_debugger)?D_SELECTED:0;
8416 misc_menu[13].flags =(zscript_debugger)?D_SELECTED:0;
8417 misc_menu[14].flags =(clearConsoleOnLoad)?D_SELECTED:0;
8418
8419 the_player_menu[2].flags = replay_is_replaying() ? D_DISABLED : 0;
8420 cheat_menu[0].flags = 0;
8421 refill_menu[4].flags = get_bit(quest_rules, qr_TRUEARROWS) ? 0 : D_DISABLED;
8422 cheat_menu[1].text = (cheat >= 1) || get_debug() ? bar_str : NULL;
8423 cheat_menu[3].text = (cheat >= 2) || get_debug() ? bar_str : NULL;
8424 cheat_menu[8].text = (cheat >= 3) || get_debug() ? bar_str : NULL;
8425 cheat_menu[10].text = (cheat >= 4) || get_debug() ? bar_str : NULL;
8426 cheat_menu[4].flags = getClock() ? D_SELECTED : 0;
8427 cheat_menu[11].flags = toogam ? D_SELECTED : 0;
8428 cheat_menu[12].flags = ignoreSideview ? D_SELECTED : 0;
8429 cheat_menu[13].flags = gofast ? D_SELECTED : 0;
8430
8431 show_menu[0].flags = show_layer_0 ? D_SELECTED : 0;
8432 show_menu[1].flags = show_layer_1 ? D_SELECTED : 0;
8433 show_menu[2].flags = show_layer_2 ? D_SELECTED : 0;
8434 show_menu[3].flags = show_layer_3 ? D_SELECTED : 0;
8435 show_menu[4].flags = show_layer_4 ? D_SELECTED : 0;
8436 show_menu[5].flags = show_layer_5 ? D_SELECTED : 0;
8437 show_menu[6].flags = show_layer_6 ? D_SELECTED : 0;
8438 show_menu[7].flags = show_layer_over ? D_SELECTED : 0;
8439 show_menu[8].flags = show_layer_push ? D_SELECTED : 0;
8440 show_menu[9].flags = show_sprites ? D_SELECTED : 0;
8441 show_menu[10].flags = show_ffcs ? D_SELECTED : 0;
8442 show_menu[12].flags = show_walkflags ? D_SELECTED : 0;
8443 show_menu[13].flags = show_ff_scripts ? D_SELECTED : 0;
8444 show_menu[14].flags = show_hitboxes ? D_SELECTED : 0;
8445 show_menu[15].flags = show_effectflags ? D_SELECTED : 0;
8446
8447 settings_menu[14].flags = heart_beep ? D_SELECTED : 0;
8448 settings_menu[15].flags = use_save_indicator ? D_SELECTED : 0;
8449
8450 replay_menu[0].text = zc_get_config("zeldadx", "replay_new_saves", false) ?
8451 (char *)"Disable recording new saves" :
8452 (char *)"Enable recording new saves";
8453 replay_menu[1].flags = replay_is_active() ? 0 : D_DISABLED;
8454 replay_menu[1].text = replay_get_mode() == ReplayMode::Record ?
8455 (char *)"Stop recording" :
8456 (char *)"Stop replaying";
8457 replay_menu[5].flags = replay_get_mode() == ReplayMode::Record ? 0 : D_DISABLED;
8458 replay_menu[6].text = replay_is_snapshot_all_frames() ?
8459 (char *)"Disable snapshot all frames" :
8460 (char *)"Enable snapshot all frames";
8461
8462 reset_snapshot_format_menu();
8463 snapshot_format_menu[SnapshotFormat].flags = D_SELECTED;
8464
8465 if(debug_enabled)
8466 {
8467 settings_menu[19].flags = get_debug() ? D_SELECTED : 0;
8468 }
8469
8470 if(gui_mouse_b() && !mouse_down)
8471 break;
8472
8473 // press menu to drop the menu
8474 if(rMbtn())
8475 simulate_keypress(KEY_G << 8);
8476
8477 if(input_idle(true) > after_time())
8478 // run Screeen Saver
8479 {
8480 // Screen saver enabled for now.
8481 clear_keybuf();
8482 scare_mouse();
8483 Matrix(ss_speed, ss_density, 0);
8484 system_pal();
8485 unscare_mouse();
8486 broadcast_dialog_message(MSG_DRAW, 0);
8487 }
8488
8489 update_hw_screen();
8490 }
8491 while(update_dialog(p));
8492
8493 screen = oldscreen;
8494
8495 // font=oldfont;
8496 mouse_down=gui_mouse_b();
8497 shutdown_dialog(p);
8498 show_mouse(NULL);
8499 MenuOpen = false;
8500 if(Quit)
8501 {
8502 kill_sfx();
8503 music_stop();
8504 update_hw_screen();
8505 }
8506 else
8507 {
8508 game_pal();
8509 music_resume();
8510 resume_all_sfx();
8511
8512 if(rc)
8513 ringcolor(false);
8514 }
8515
8516 eat_buttons();
8517
8518 rc=false;
8519 clear_keybuf();
8520 // text_mode(0);
8521 }
8522
8523 29 void fix_dialogs()
8524 {
8525 29 jwin_center_dialog(about_dlg);
8526 29 jwin_center_dialog(gamepad_dlg);
8527 29 jwin_center_dialog(credits_dlg);
8528 29 jwin_center_dialog(gamemode_dlg);
8529 29 jwin_center_dialog(getnum_dlg);
8530 29 jwin_center_dialog(goto_dlg);
8531 29 jwin_center_dialog(keyboard_control_dlg);
8532 29 jwin_center_dialog(midi_dlg);
8533 29 jwin_center_dialog(quest_dlg);
8534 29 jwin_center_dialog(scrsaver_dlg);
8535 29 jwin_center_dialog(sound_dlg);
8536 29 jwin_center_dialog(triforce_dlg);
8537
8538 // digi_dp[1] += scrx;
8539 // digi_dp[2] += scry;
8540 // midi_dp[1] += scrx;
8541 // midi_dp[2] += scry;
8542 // pan_dp[1] += scrx;
8543 // pan_dp[2] += scry;
8544 // emus_dp[1] += scrx;
8545 // emus_dp[2] += scry;
8546 // buf_dp[1] += scrx;
8547 // buf_dp[2] += scry;
8548 // sfx_dp[1] += scrx;
8549 // sfx_dp[2] += scry;
8550 29 }
8551
8552 /*****************************/
8553 /**** Custom Sound System ****/
8554 /*****************************/
8555
8556 2295 INLINE int32_t mixvol(int32_t v1,int32_t v2)
8557 {
8558
3/4
✓ Branch 0 taken 2061 times.
✓ Branch 1 taken 234 times.
✓ Branch 2 taken 2295 times.
✗ Branch 3 not taken.
2295 return (zc_min(v1,255)*zc_min(v2,255)) >> 8;
8559 }
8560
8561 // Run an NSF, or a MIDI if the NSF is missing somehow.
8562 83 bool try_zcmusic(char *filename, int32_t track, int32_t midi)
8563 {
8564 83 ZCMUSIC *newzcmusic = zcmusic_load_for_quest(filename, qstpath);
8565
8566 // Found it
8567
2/2
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 35 times.
83 if(newzcmusic!=NULL)
8568 {
8569 48 zcmusic_stop(zcmusic);
8570 48 zcmusic_unload_file(zcmusic);
8571 48 zc_stop_midi();
8572
8573 48 zcmusic=newzcmusic;
8574 48 zcmusic_play(zcmusic, emusic_volume);
8575
8576
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
48 if(track>0)
8577 48 zcmusic_change_track(zcmusic,track);
8578
8579 48 return true;
8580 }
8581
8582 // Not found, play MIDI - unless this was called by a script (yay, magic numbers)
8583
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 else if(midi>-1000)
8584 jukebox(midi);
8585
8586 35 return false;
8587 83 }
8588
8589 bool try_zcmusic_ex(char *filename, int32_t track, int32_t midi)
8590 {
8591 ZCMUSIC *newzcmusic = zcmusic_load_for_quest(filename, qstpath);
8592 // Found it
8593 if(newzcmusic!=NULL)
8594 {
8595 zcmusic_stop(zcmusic);
8596 zcmusic_unload_file(zcmusic);
8597 zc_stop_midi();
8598
8599 zcmusic=newzcmusic;
8600 zcmusic_play(zcmusic, emusic_volume);
8601
8602 if(track>0)
8603 zcmusic_change_track(zcmusic,track);
8604
8605 return true;
8606 }
8607
8608 // Not found, play MIDI - unless this was called by a script (yay, magic numbers)
8609 else if(midi>-1000)
8610 jukebox(midi);
8611
8612 return false;
8613 }
8614
8615 int32_t get_zcmusicpos()
8616 {
8617 int32_t debugtracething = zcmusic_get_curpos(zcmusic);
8618 return debugtracething;
8619 return 0;
8620 }
8621
8622 void set_zcmusicpos(int32_t position)
8623 {
8624 zcmusic_set_curpos(zcmusic, position);
8625 }
8626
8627 void set_zcmusicspeed(int32_t speed)
8628 {
8629 int32_t newspeed = vbound(speed, 0, 10000);
8630 zcmusic_set_speed(zcmusic, newspeed);
8631 }
8632
8633 1133 void jukebox(int32_t index,int32_t loop)
8634 {
8635 1133 music_stop();
8636
8637
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1133 times.
1133 if(index<0) index=MAXMIDIS-1;
8638
8639
1/2
✓ Branch 0 taken 1133 times.
✗ Branch 1 not taken.
1133 if(index>=MAXMIDIS) index=0;
8640
8641 1133 music_stop();
8642
8643 // Allegro's DIGMID driver (the one normally used on on Linux) gets
8644 // stuck notes when a song stops. This fixes it.
8645
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1133 times.
1133 if(strcmp(midi_driver->name, "DIGMID")==0)
8646 zc_set_volume(0, 0);
8647
8648 1133 zc_set_volume(-1, mixvol(tunes[index].volume,midi_volume>>1));
8649 1133 zc_play_midi((MIDI*)tunes[index].data,loop);
8650
8651
2/2
✓ Branch 0 taken 756 times.
✓ Branch 1 taken 377 times.
1133 if(tunes[index].start>0)
8652 377 zc_midi_seek(tunes[index].start);
8653
8654 1133 midi_loop_start = tunes[index].loop_start;
8655 1133 midi_loop_end = tunes[index].loop_end;
8656
8657 1133 currmidi=index;
8658 1133 master_volume(digi_volume,midi_volume);
8659 1133 midi_paused=false;
8660 1133 }
8661
8662 8589 void jukebox(int32_t index)
8663 {
8664
1/2
✓ Branch 0 taken 8589 times.
✗ Branch 1 not taken.
8589 if(index<0) index=MAXMIDIS-1;
8665
8666
1/2
✓ Branch 0 taken 8589 times.
✗ Branch 1 not taken.
8589 if(index>=MAXMIDIS) index=0;
8667
8668 // do nothing if it's already playing
8669
3/4
✓ Branch 0 taken 7456 times.
✓ Branch 1 taken 1133 times.
✓ Branch 2 taken 7456 times.
✗ Branch 3 not taken.
8589 if(index==currmidi && midi_pos>=0)
8670 {
8671 7456 midi_paused=false;
8672 7456 return;
8673 }
8674
8675 1133 jukebox(index,tunes[index].loop);
8676 8589 }
8677
8678 9829 void play_DmapMusic()
8679 {
8680 static char tfile[2048];
8681 static int32_t ttrack=0;
8682 9829 bool domidi=false;
8683
8684
2/2
✓ Branch 0 taken 1330 times.
✓ Branch 1 taken 8499 times.
9829 if(DMaps[currdmap].tmusic[0]!=0)
8685 {
8686
3/4
✓ Branch 0 taken 385 times.
✓ Branch 1 taken 945 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 385 times.
1715 if(zcmusic==NULL ||
8687
1/2
✓ Branch 0 taken 385 times.
✗ Branch 1 not taken.
385 strcmp(zcmusic->filename,DMaps[currdmap].tmusic)!=0 ||
8688
1/2
✓ Branch 0 taken 385 times.
✗ Branch 1 not taken.
385 (zcmusic->type==ZCMF_GME && zcmusic->track != DMaps[currdmap].tmusictrack))
8689 {
8690
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 945 times.
945 if(zcmusic != NULL)
8691 {
8692 zcmusic_stop(zcmusic);
8693 zcmusic_unload_file(zcmusic);
8694 zcmusic = NULL;
8695 }
8696
8697 945 zcmusic = zcmusic_load_for_quest(DMaps[currdmap].tmusic, qstpath);
8698
8699
2/2
✓ Branch 0 taken 86 times.
✓ Branch 1 taken 859 times.
945 if(zcmusic!=NULL)
8700 {
8701 86 zc_stop_midi();
8702 86 strcpy(tfile,DMaps[currdmap].tmusic);
8703 86 zcmusic_play(zcmusic, emusic_volume);
8704 86 int32_t temptracks=0;
8705 86 temptracks=zcmusic_get_tracks(zcmusic);
8706
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 86 times.
86 temptracks=(temptracks<2)?1:temptracks;
8707 86 ttrack = vbound(DMaps[currdmap].tmusictrack,0,temptracks-1);
8708 86 zcmusic_change_track(zcmusic,ttrack);
8709 86 }
8710 else
8711 {
8712 859 tfile[0] = 0;
8713 859 domidi=true;
8714 }
8715 945 }
8716 1330 }
8717 else
8718 {
8719 8499 domidi=true;
8720 }
8721
8722
2/2
✓ Branch 0 taken 471 times.
✓ Branch 1 taken 9358 times.
9829 if(domidi)
8723 {
8724 9358 int32_t m=DMaps[currdmap].midi;
8725
8726
3/4
✓ Branch 0 taken 9243 times.
✓ Branch 1 taken 105 times.
✓ Branch 2 taken 10 times.
✗ Branch 3 not taken.
9358 switch(m)
8727 {
8728 case 1:
8729 105 jukebox(ZC_MIDI_OVERWORLD);
8730 105 break;
8731
8732 case 2:
8733 10 jukebox(ZC_MIDI_DUNGEON);
8734 10 break;
8735
8736 case 3:
8737 jukebox(ZC_MIDI_LEVEL9);
8738 break;
8739
8740 default:
8741
3/4
✓ Branch 0 taken 8329 times.
✓ Branch 1 taken 914 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 8329 times.
9243 if(m>=4 && m<4+MAXCUSTOMMIDIS)
8742 8329 jukebox(m+MIDIOFFSET_DMAP);
8743 else
8744 914 music_stop();
8745 9243 }
8746 9358 }
8747 9829 }
8748
8749 9866 void playLevelMusic()
8750 {
8751 9866 int32_t m=tmpscr->screen_midi;
8752
8753
3/6
✓ Branch 0 taken 9813 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 41 times.
✓ Branch 4 taken 12 times.
✗ Branch 5 not taken.
9866 switch(m)
8754 {
8755 case -2:
8756 12 music_stop();
8757 12 break;
8758
8759 case -1:
8760 9813 play_DmapMusic();
8761 9813 break;
8762
8763 case 1:
8764 jukebox(ZC_MIDI_OVERWORLD);
8765 break;
8766
8767 case 2:
8768 jukebox(ZC_MIDI_DUNGEON);
8769 break;
8770
8771 case 3:
8772 jukebox(ZC_MIDI_LEVEL9);
8773 break;
8774
8775 default:
8776
2/4
✓ Branch 0 taken 41 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 41 times.
✗ Branch 3 not taken.
41 if(m>=4 && m<4+MAXCUSTOMMIDIS)
8777 41 jukebox(m+MIDIOFFSET_MAPSCR);
8778 else
8779 music_stop();
8780 41 }
8781 9866 }
8782
8783 1162 void master_volume(int32_t dv,int32_t mv)
8784 {
8785
4/8
✗ Branch 0 not taken.
✓ Branch 1 taken 1162 times.
✓ Branch 2 taken 1162 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1162 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1162 times.
✗ Branch 7 not taken.
1162 if(dv>=0) digi_volume=zc_max(zc_min(dv,255),0);
8786
8787
4/8
✗ Branch 0 not taken.
✓ Branch 1 taken 1162 times.
✓ Branch 2 taken 1162 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1162 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1162 times.
✗ Branch 7 not taken.
1162 if(mv>=0) midi_volume=zc_max(zc_min(mv,255),0);
8788
8789
6/6
✓ Branch 0 taken 1132 times.
✓ Branch 1 taken 30 times.
✓ Branch 2 taken 1160 times.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 1130 times.
✓ Branch 5 taken 30 times.
1162 int32_t i = zc_min(zc_max(currmidi,0),MAXMIDIS-1);
8790 1162 zc_set_volume(digi_volume,mixvol(tunes[i].volume,midi_volume));
8791 1162 }
8792
8793 /*****************/
8794 /***** SFX *****/
8795 /*****************/
8796
8797 // array of voices, one for each sfx sample in the data file
8798 // 0+ = voice #
8799 // -1 = voice not allocated
8800 29 void Z_init_sound()
8801 {
8802
2/2
✓ Branch 0 taken 7424 times.
✓ Branch 1 taken 29 times.
7453 for(int32_t i=0; i<WAV_COUNT; i++)
8803 7424 sfx_voice[i]=-1;
8804
8805
2/2
✓ Branch 0 taken 203 times.
✓ Branch 1 taken 29 times.
232 for(int32_t i=0; i<ZC_MIDI_COUNT; i++)
8806 203 tunes[i].data = (MIDI*)mididata[i].dat;
8807
8808
2/2
✓ Branch 0 taken 7308 times.
✓ Branch 1 taken 29 times.
7337 for(int32_t j=0; j<MAXCUSTOMMIDIS; j++)
8809 7308 tunes[ZC_MIDI_COUNT+j].data=NULL;
8810
8811 29 master_volume(digi_volume,midi_volume);
8812 29 }
8813
8814 // returns number of voices currently allocated
8815 int32_t sfx_count()
8816 {
8817 int32_t c=0;
8818
8819 for(int32_t i=0; i<WAV_COUNT; i++)
8820 if(sfx_voice[i]!=-1)
8821 ++c;
8822
8823 return c;
8824 }
8825
8826 // clean up finished samples
8827 6480723 void sfx_cleanup()
8828 {
8829
2/2
✓ Branch 0 taken 1659065088 times.
✓ Branch 1 taken 6480723 times.
1665545811 for(int32_t i=0; i<WAV_COUNT; i++)
8830
3/4
✓ Branch 0 taken 560755 times.
✓ Branch 1 taken 1658504333 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 560755 times.
1659625843 if(sfx_voice[i]!=-1 && voice_get_position(sfx_voice[i])<0)
8831 {
8832 560755 deallocate_voice(sfx_voice[i]);
8833 560755 sfx_voice[i]=-1;
8834 560755 }
8835 6480723 }
8836
8837 // allocates a voice for the sample "wav_index" (index into zelda.dat)
8838 // if a voice is already allocated (and/or playing), then it just returns true
8839 // Returns true: voice is allocated
8840 // false: unsuccessful
8841 815922 bool sfx_init(int32_t index)
8842 {
8843 // check index
8844
3/4
✓ Branch 0 taken 620761 times.
✓ Branch 1 taken 195161 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 620761 times.
815922 if(index<=0 || index>=WAV_COUNT)
8845 195161 return false;
8846
8847
2/2
✓ Branch 0 taken 59980 times.
✓ Branch 1 taken 560781 times.
620761 if(sfx_voice[index]==-1)
8848 {
8849
2/2
✓ Branch 0 taken 110294 times.
✓ Branch 1 taken 450487 times.
560781 if(sfxdat)
8850 {
8851
1/2
✓ Branch 0 taken 110294 times.
✗ Branch 1 not taken.
110294 if(index<Z35)
8852 {
8853 110294 sfx_voice[index]=allocate_voice((SAMPLE*)sfxdata[index].dat);
8854 110294 }
8855 else
8856 {
8857 sfx_voice[index]=allocate_voice((SAMPLE*)sfxdata[Z35].dat);
8858 }
8859 110294 }
8860 else
8861 {
8862 450487 sfx_voice[index]=allocate_voice(&customsfxdata[index]);
8863 }
8864
8865 560781 voice_set_volume(sfx_voice[index], sfx_volume);
8866 560781 }
8867
8868 620761 return sfx_voice[index] != -1;
8869 815922 }
8870
8871 // plays an sfx sample
8872 709410 void sfx(int32_t index,int32_t pan,bool loop, bool restart)
8873 {
8874
2/2
✓ Branch 0 taken 550996 times.
✓ Branch 1 taken 158414 times.
709410 if(!sfx_init(index))
8875 158414 return;
8876
8877 550996 voice_set_playmode(sfx_voice[index],loop?PLAYMODE_LOOP:PLAYMODE_PLAY);
8878 550996 voice_set_pan(sfx_voice[index],pan);
8879
8880 550996 int32_t pos = voice_get_position(sfx_voice[index]);
8881
8882
2/2
✓ Branch 0 taken 300453 times.
✓ Branch 1 taken 250543 times.
550996 if(restart) voice_set_position(sfx_voice[index],0);
8883
8884
1/2
✓ Branch 0 taken 550996 times.
✗ Branch 1 not taken.
550996 if(pos<=0)
8885 550996 voice_start(sfx_voice[index]);
8886 709410 }
8887
8888 // true if sfx is allocated
8889 21673 bool sfx_allocated(int32_t index)
8890 {
8891
2/4
✓ Branch 0 taken 21673 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 21673 times.
21673 return (index>0 && index<WAV_COUNT && sfx_voice[index]!=-1);
8892 }
8893
8894 // start it (in loop mode) if it's not already playing,
8895 // otherwise adjust it to play in loop mode -DD
8896 106512 void cont_sfx(int32_t index)
8897 {
8898
2/2
✓ Branch 0 taken 36747 times.
✓ Branch 1 taken 69765 times.
106512 if(!sfx_init(index))
8899 {
8900 36747 return;
8901 }
8902
8903
1/2
✓ Branch 0 taken 69765 times.
✗ Branch 1 not taken.
69765 if(voice_get_position(sfx_voice[index])<=0)
8904 {
8905 69765 voice_set_position(sfx_voice[index],0);
8906 69765 voice_set_playmode(sfx_voice[index],PLAYMODE_LOOP);
8907 69765 voice_start(sfx_voice[index]);
8908 69765 }
8909 else
8910 {
8911 adjust_sfx(index, 128, true);
8912 }
8913 106512 }
8914
8915 // adjust parameters while playing
8916 3547 void adjust_sfx(int32_t index,int32_t pan,bool loop)
8917 {
8918
5/6
✓ Branch 0 taken 2124 times.
✓ Branch 1 taken 1423 times.
✓ Branch 2 taken 2124 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 14 times.
✓ Branch 5 taken 2110 times.
3547 if(index<=0 || index>=WAV_COUNT || sfx_voice[index]==-1)
8919 3533 return;
8920
8921 14 voice_set_playmode(sfx_voice[index],loop?PLAYMODE_LOOP:PLAYMODE_PLAY);
8922 14 voice_set_pan(sfx_voice[index],pan);
8923 3547 }
8924
8925 // pauses a voice
8926 1468 void pause_sfx(int32_t index)
8927 {
8928
3/6
✓ Branch 0 taken 1468 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1468 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1468 times.
1468 if(index>0 && index<WAV_COUNT && sfx_voice[index]!=-1)
8929 voice_stop(sfx_voice[index]);
8930 1468 }
8931
8932 // resumes a voice
8933 637 void resume_sfx(int32_t index)
8934 {
8935
3/6
✓ Branch 0 taken 637 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 637 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 637 times.
637 if(index>0 && index<WAV_COUNT && sfx_voice[index]!=-1)
8936 voice_start(sfx_voice[index]);
8937 637 }
8938
8939 // pauses all active voices
8940 244 void pause_all_sfx()
8941 {
8942
2/2
✓ Branch 0 taken 62464 times.
✓ Branch 1 taken 244 times.
62708 for(int32_t i=0; i<WAV_COUNT; i++)
8943
2/2
✓ Branch 0 taken 62462 times.
✓ Branch 1 taken 2 times.
62466 if(sfx_voice[i]!=-1)
8944 2 voice_stop(sfx_voice[i]);
8945 244 }
8946
8947 // resumes all paused voices
8948 230 void resume_all_sfx()
8949 {
8950
2/2
✓ Branch 0 taken 58880 times.
✓ Branch 1 taken 230 times.
59110 for(int32_t i=0; i<WAV_COUNT; i++)
8951
1/2
✓ Branch 0 taken 58880 times.
✗ Branch 1 not taken.
58880 if(sfx_voice[i]!=-1)
8952 voice_start(sfx_voice[i]);
8953 230 }
8954
8955 // stops an sfx and deallocates the voice
8956 5203476 void stop_sfx(int32_t index)
8957 {
8958
3/4
✓ Branch 0 taken 5102116 times.
✓ Branch 1 taken 101360 times.
✓ Branch 2 taken 5102116 times.
✗ Branch 3 not taken.
5203476 if(index<=0 || index>=WAV_COUNT)
8959 101360 return;
8960
8961
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 5102103 times.
5102116 if(sfx_voice[index]!=-1)
8962 {
8963 13 deallocate_voice(sfx_voice[index]);
8964 13 sfx_voice[index]=-1;
8965 13 }
8966 5203476 }
8967
8968 // Stops SFX played by Hero's item of the given family
8969 131169 void stop_item_sfx(int32_t family)
8970 {
8971 131169 int32_t id=current_item_id(family);
8972
8973
2/2
✓ Branch 0 taken 130841 times.
✓ Branch 1 taken 328 times.
131169 if(id<0)
8974 130841 return;
8975
8976 328 stop_sfx(itemsbuf[id].usesound);
8977 131169 }
8978
8979 1802 void kill_sfx()
8980 {
8981
2/2
✓ Branch 0 taken 461312 times.
✓ Branch 1 taken 1802 times.
463114 for(int32_t i=0; i<WAV_COUNT; i++)
8982
2/2
✓ Branch 0 taken 461299 times.
✓ Branch 1 taken 13 times.
461325 if(sfx_voice[i]!=-1)
8983 {
8984 13 deallocate_voice(sfx_voice[i]);
8985 13 sfx_voice[i]=-1;
8986 13 }
8987 1802 }
8988
8989 481358 int32_t pan(int32_t x)
8990 {
8991
1/4
✓ Branch 0 taken 481358 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
481358 switch(pan_style)
8992 {
8993 case 0:
8994 return 128;
8995
8996 case 1:
8997 481358 return vbound((x>>1)+68,0,255);
8998
8999 case 2:
9000 return vbound(((x*3)>>2)+36,0,255);
9001 }
9002
9003 return vbound(x,0,255);
9004 481358 }
9005
9006 /*******************************/
9007 /******* Input Handlers ********/
9008 /*******************************/
9009
9010 16584516 bool joybtn(int32_t b)
9011 {
9012
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16584516 times.
16584516 if(b == 0)
9013 return false;
9014
9015 16584516 return joy[joystick_index].button[b-1].b !=0;
9016 16584516 }
9017
9018 const char* joybtn_name(int32_t b)
9019 {
9020 if(b == 0)
9021 return "";
9022
9023 return joy[joystick_index].button[b-1].name;
9024 }
9025
9026 int32_t next_press_key();
9027
9028 int32_t next_press_btn()
9029 {
9030 clear_keybuf();
9031 /*bool b[joy[joystick_index].num_buttons+1];
9032
9033 for(int32_t i=1; i<=joy[joystick_index].num_buttons; i++)
9034 b[i]=joybtn(i);*/
9035
9036 //first, we need to wait until they're pressing no buttons
9037 for(;;)
9038 {
9039 if(keypressed())
9040 {
9041 switch(readkey()>>8)
9042 {
9043 case KEY_ESC:
9044 return -1;
9045
9046 case KEY_SPACE:
9047 return 0;
9048 }
9049 }
9050
9051 poll_joystick();
9052 bool done = true;
9053
9054 for(int32_t i=1; i<=joy[joystick_index].num_buttons; i++)
9055 {
9056 if(joybtn(i)) done = false;
9057 }
9058
9059 if(done) break;
9060 rest(1);
9061 }
9062
9063 //now, we need to wait for them to press any button
9064 for(;;)
9065 {
9066 if(keypressed())
9067 {
9068 switch(readkey()>>8)
9069 {
9070 case KEY_ESC:
9071 return -1;
9072
9073 case KEY_SPACE:
9074 return 0;
9075 }
9076 }
9077
9078 poll_joystick();
9079
9080 for(int32_t i=1; i<=joy[joystick_index].num_buttons; i++)
9081 {
9082 if(joybtn(i)) return i;
9083 }
9084 rest(1);
9085 }
9086 }
9087
9088 134626390 static bool rButton(bool &btn, bool &flag, bool* rawbtn = nullptr)
9089 {
9090
2/2
✓ Branch 0 taken 129836505 times.
✓ Branch 1 taken 4789885 times.
134626390 bool ret = btn && !flag;
9091
2/2
✓ Branch 0 taken 117582881 times.
✓ Branch 1 taken 17043509 times.
134626390 flag = rawbtn ? *rawbtn : btn;
9092
9093 134626390 return ret;
9094 }
9095 10039 static bool rButtonPeek(bool btn, bool flag)
9096 {
9097
2/2
✓ Branch 0 taken 9794 times.
✓ Branch 1 taken 245 times.
10039 if(!btn)
9098 {
9099 9794 return false;
9100 }
9101
2/2
✓ Branch 0 taken 52 times.
✓ Branch 1 taken 193 times.
245 else if(!flag)
9102 {
9103 52 return true;
9104 }
9105
9106 193 return false;
9107 10039 }
9108
9109 // Updated only by keyboard/gamepad.
9110 // If in replay mode, this is set directly by the replay system.
9111 // This should never be read from directly - use control_state instead.
9112 bool raw_control_state[ZC_CONTROL_STATES];
9113
9114 // Every call to load_control_state (pretty much every frame) resets this to be equal to raw_control_state.
9115 // This state can drift from raw_control_state if button states are "eaten" or overriden by a script. But that only
9116 // lasts until the next call to load_control_state.
9117 bool control_state[ZC_CONTROL_STATES];
9118 bool disable_control[ZC_CONTROL_STATES];
9119 bool drunk_toggle_state[11];
9120 bool disabledKeys[127];
9121 bool KeyInput[127];
9122 bool KeyPress[127];
9123
9124 bool key_current_frame[127];
9125 bool key_previous_frame[127];
9126
9127 static bool key_system[127];
9128 static bool key_system_previous[127];
9129 static bool key_system_press[127];
9130
9131 bool button_press[ZC_CONTROL_STATES];
9132 bool button_hold[ZC_CONTROL_STATES];
9133
9134 #define STICK_1_X joy[joystick_index].stick[js_stick_1_x_stick].axis[js_stick_1_x_axis]
9135 #define STICK_1_Y joy[joystick_index].stick[js_stick_1_y_stick].axis[js_stick_1_y_axis]
9136 #define STICK_2_X joy[joystick_index].stick[js_stick_2_x_stick].axis[js_stick_2_x_axis]
9137 #define STICK_2_Y joy[joystick_index].stick[js_stick_2_y_stick].axis[js_stick_2_y_axis]
9138 #define STICK_PRECISION 56 //define your own sensitivity
9139
9140 5438197 void load_control_state()
9141 {
9142 5438197 load_control_called_this_frame = true;
9143
9144
3/4
✓ Branch 0 taken 2566996 times.
✓ Branch 1 taken 2871201 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2566996 times.
5438197 if (replay_get_version() >= 8 && replay_get_version() < 11)
9145 {
9146
2/2
✓ Branch 0 taken 46205928 times.
✓ Branch 1 taken 2566996 times.
48772924 for (int i = 0; i < ZC_CONTROL_STATES; i++)
9147 46205928 down_control_states[i] = raw_control_state[i];
9148 2566996 }
9149
9150
1/2
✓ Branch 0 taken 5438197 times.
✗ Branch 1 not taken.
5438197 if (!replay_is_replaying())
9151 {
9152 raw_control_state[0]=zc_getrawkey(DUkey, true)||(analog_movement ? STICK_1_Y.d1 || STICK_1_Y.pos - js_stick_1_y_offset < -STICK_PRECISION : joybtn(DUbtn));
9153 raw_control_state[1]=zc_getrawkey(DDkey, true)||(analog_movement ? STICK_1_Y.d2 || STICK_1_Y.pos - js_stick_1_y_offset > STICK_PRECISION : joybtn(DDbtn));
9154 raw_control_state[2]=zc_getrawkey(DLkey, true)||(analog_movement ? STICK_1_X.d1 || STICK_1_X.pos - js_stick_1_x_offset < -STICK_PRECISION : joybtn(DLbtn));
9155 raw_control_state[3]=zc_getrawkey(DRkey, true)||(analog_movement ? STICK_1_X.d2 || STICK_1_X.pos - js_stick_1_x_offset > STICK_PRECISION : joybtn(DRbtn));
9156 raw_control_state[4]=zc_getrawkey(Akey, true)||joybtn(Abtn);
9157 raw_control_state[5]=zc_getrawkey(Bkey, true)||joybtn(Bbtn);
9158 raw_control_state[6]=zc_getrawkey(Skey, true)||joybtn(Sbtn);
9159 raw_control_state[7]=zc_getrawkey(Lkey, true)||joybtn(Lbtn);
9160 raw_control_state[8]=zc_getrawkey(Rkey, true)||joybtn(Rbtn);
9161 raw_control_state[9]=zc_getrawkey(Pkey, true)||joybtn(Pbtn);
9162 raw_control_state[10]=zc_getrawkey(Exkey1, true)||joybtn(Exbtn1);
9163 raw_control_state[11]=zc_getrawkey(Exkey2, true)||joybtn(Exbtn2);
9164 raw_control_state[12]=zc_getrawkey(Exkey3, true)||joybtn(Exbtn3);
9165 raw_control_state[13]=zc_getrawkey(Exkey4, true)||joybtn(Exbtn4);
9166
9167 if(num_joysticks != 0)
9168 {
9169 raw_control_state[14] = STICK_2_Y.pos - js_stick_2_y_offset < -STICK_PRECISION;
9170 raw_control_state[15] = STICK_2_Y.pos - js_stick_2_y_offset > STICK_PRECISION;
9171 raw_control_state[16] = STICK_2_X.pos - js_stick_2_x_offset < -STICK_PRECISION;
9172 raw_control_state[17] = STICK_2_X.pos - js_stick_2_x_offset > STICK_PRECISION;
9173 // zprint2("Detected %d joysticks... %d%d%d%d\n", num_joysticks, raw_control_state[14]?1:0, raw_control_state[15]?1:0, raw_control_state[16]?1:0, raw_control_state[17]?1:0);
9174 }
9175 else
9176 {
9177 raw_control_state[14] = false;
9178 raw_control_state[15] = false;
9179 raw_control_state[16] = false;
9180 raw_control_state[17] = false;
9181 // zprint2("Detected 0 joysticks... clearing inputaxis values.\n");
9182 }
9183 }
9184
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 5438194 times.
5438197 if (replay_is_active())
9185 {
9186
2/2
✓ Branch 0 taken 1015215 times.
✓ Branch 1 taken 4422979 times.
5438194 if (replay_get_version() < 3)
9187 1015215 replay_poll();
9188
3/4
✓ Branch 0 taken 4422979 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2661604 times.
✓ Branch 3 taken 1761375 times.
4422979 else if (replay_is_replaying() && replay_get_version() < 6)
9189 1761375 replay_peek_input();
9190
4/6
✓ Branch 0 taken 2661604 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2566996 times.
✓ Branch 3 taken 94608 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2566996 times.
2661604 else if (replay_is_replaying() && replay_get_version() >= 8 && replay_get_version() < 11)
9191 2566996 replay_peek_input();
9192
2/2
✓ Branch 0 taken 4320728 times.
✓ Branch 1 taken 1117466 times.
5438194 if (replay_get_version() == 8)
9193 1117466 update_keys();
9194 5438194 }
9195
9196 // Some test replay files were made before a serious input bug was fixed, so instead
9197 // of re-doing them or tossing them out, just check for that zplay version.
9198
3/4
✓ Branch 0 taken 5438191 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 121900 times.
✓ Branch 3 taken 5316291 times.
5438197 bool botched_input = replay_is_active() && replay_get_version() != 1 && replay_get_version() < 8;
9199
2/2
✓ Branch 0 taken 97887438 times.
✓ Branch 1 taken 5438191 times.
103325629 for (int i = 0; i < ZC_CONTROL_STATES; i++)
9200 {
9201 97887438 control_state[i] = raw_control_state[i];
9202
4/4
✓ Branch 0 taken 49487310 times.
✓ Branch 1 taken 48400128 times.
✓ Branch 2 taken 2410168 times.
✓ Branch 3 taken 47077142 times.
97887438 if (botched_input && !control_state[i])
9203 47077142 down_control_states[i] = false;
9204 97887438 }
9205
9206 5438191 button_press[0]=rButton(control_state[0],button_hold[0]);
9207 5438191 button_press[1]=rButton(control_state[1],button_hold[1]);
9208 5438191 button_press[2]=rButton(control_state[2],button_hold[2]);
9209 5438191 button_press[3]=rButton(control_state[3],button_hold[3]);
9210 5438191 button_press[4]=rButton(control_state[4],button_hold[4]);
9211 5438191 button_press[5]=rButton(control_state[5],button_hold[5]);
9212 5438191 button_press[6]=rButton(control_state[6],button_hold[6]);
9213 5438191 button_press[7]=rButton(control_state[7],button_hold[7]);
9214 5438191 button_press[8]=rButton(control_state[8],button_hold[8]);
9215 5438191 button_press[9]=rButton(control_state[9],button_hold[9]);
9216 5438191 button_press[10]=rButton(control_state[10],button_hold[10]);
9217 5438191 button_press[11]=rButton(control_state[11],button_hold[11]);
9218 5438191 button_press[12]=rButton(control_state[12],button_hold[12]);
9219 5438191 button_press[13]=rButton(control_state[13],button_hold[13]);
9220 5438191 button_press[14]=rButton(control_state[14],button_hold[14]);
9221 5438191 button_press[15]=rButton(control_state[15],button_hold[15]);
9222 5438191 button_press[16]=rButton(control_state[16],button_hold[16]);
9223 5438191 button_press[17]=rButton(control_state[17],button_hold[17]);
9224 5438191 }
9225
9226 // Returns true if any game key is pressed. This is needed because keypressed()
9227 // doesn't detect modifier keys and control_state[] can be modified by scripts.
9228 28178162 bool zc_key_pressed()
9229 //may also need to use zc_getrawkey
9230 {
9231
7/10
✓ Branch 0 taken 22800161 times.
✓ Branch 1 taken 5378001 times.
✓ Branch 2 taken 5378001 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 5378001 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 4533401 times.
✓ Branch 7 taken 4533401 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 1621032 times.
29799194 if((zc_getrawkey(DUkey, true)||(analog_movement ? STICK_1_Y.d1 || STICK_1_Y.pos - js_stick_1_y_offset< -STICK_PRECISION : joybtn(DUbtn))) ||
9232
4/6
✓ Branch 0 taken 4533401 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4533401 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3418530 times.
✓ Branch 5 taken 3418530 times.
4533401 (zc_getrawkey(DDkey, true)||(analog_movement ? STICK_1_Y.d2 || STICK_1_Y.pos - js_stick_1_y_offset > STICK_PRECISION : joybtn(DDbtn))) ||
9233
4/6
✓ Branch 0 taken 3418530 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3418530 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2176173 times.
✓ Branch 5 taken 2176173 times.
3418530 (zc_getrawkey(DLkey, true)||(analog_movement ? STICK_1_X.d1 || STICK_1_X.pos - js_stick_1_x_offset < -STICK_PRECISION : joybtn(DLbtn))) ||
9234
4/6
✓ Branch 0 taken 2176173 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2176173 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1838283 times.
✓ Branch 5 taken 1838283 times.
2176173 (zc_getrawkey(DRkey, true)||(analog_movement ? STICK_1_X.d2 || STICK_1_X.pos - js_stick_1_x_offset > STICK_PRECISION : joybtn(DRbtn))) ||
9235
1/2
✓ Branch 0 taken 1838283 times.
✗ Branch 1 not taken.
1838283 (zc_getrawkey(Akey, true)||joybtn(Abtn)) ||
9236
3/4
✓ Branch 0 taken 1736661 times.
✓ Branch 1 taken 101622 times.
✓ Branch 2 taken 1736661 times.
✗ Branch 3 not taken.
1838283 (zc_getrawkey(Bkey, true)||joybtn(Bbtn)) ||
9237
3/4
✓ Branch 0 taken 1646160 times.
✓ Branch 1 taken 90501 times.
✓ Branch 2 taken 1646160 times.
✗ Branch 3 not taken.
1736661 (zc_getrawkey(Skey, true)||joybtn(Sbtn)) ||
9238
3/4
✓ Branch 0 taken 1633476 times.
✓ Branch 1 taken 12684 times.
✓ Branch 2 taken 1633476 times.
✗ Branch 3 not taken.
1646160 (zc_getrawkey(Lkey, true)||joybtn(Lbtn)) ||
9239
3/4
✓ Branch 0 taken 1623117 times.
✓ Branch 1 taken 10359 times.
✓ Branch 2 taken 1623117 times.
✗ Branch 3 not taken.
1633476 (zc_getrawkey(Rkey, true)||joybtn(Rbtn)) ||
9240
3/4
✓ Branch 0 taken 1621864 times.
✓ Branch 1 taken 1253 times.
✓ Branch 2 taken 1621864 times.
✗ Branch 3 not taken.
1623117 (zc_getrawkey(Pkey, true)||joybtn(Pbtn)) ||
9241
3/4
✓ Branch 0 taken 1621821 times.
✓ Branch 1 taken 43 times.
✓ Branch 2 taken 1621821 times.
✗ Branch 3 not taken.
1621864 (zc_getrawkey(Exkey1, true)||joybtn(Exbtn1)) ||
9242
3/4
✓ Branch 0 taken 1621051 times.
✓ Branch 1 taken 770 times.
✓ Branch 2 taken 1621051 times.
✗ Branch 3 not taken.
1621821 (zc_getrawkey(Exkey2, true)||joybtn(Exbtn2)) ||
9243
2/4
✓ Branch 0 taken 1621051 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1621051 times.
✗ Branch 3 not taken.
1621051 (zc_getrawkey(Exkey3, true)||joybtn(Exbtn3)) ||
9244
2/2
✓ Branch 0 taken 1621032 times.
✓ Branch 1 taken 19 times.
1621051 (zc_getrawkey(Exkey4, true)||joybtn(Exbtn4))) // Skipping joystick axes
9245 50489904 return true;
9246
9247 1621032 return false;
9248 6510614 }
9249
9250 107254410 bool getInput(int32_t btn, bool press, bool drunk, bool ignoreDisable, bool eatEntirely, bool peek)
9251 {
9252 107254410 bool ret = false, drunkstate = false, rawret = false;
9253 107254410 bool* flag = &down_control_states[btn];
9254
2/7
✓ Branch 0 taken 100736977 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 6517433 times.
107254410 switch(btn)
9255 {
9256 case btnF12:
9257 ret = zc_getkey(KEY_F12, ignoreDisable);
9258 rawret = zc_getrawkey(KEY_F12, ignoreDisable);
9259 eatEntirely = false;
9260 break;
9261 case btnF11:
9262 ret = zc_getkey(KEY_F11, ignoreDisable);
9263 rawret = zc_getrawkey(KEY_F11, ignoreDisable);
9264 eatEntirely = false;
9265 break;
9266 case btnF5:
9267 ret = zc_getkey(KEY_F5, ignoreDisable);
9268 rawret = zc_getrawkey(KEY_F5, ignoreDisable);
9269 eatEntirely = false;
9270 break;
9271 case btnQ:
9272 ret = zc_getkey(KEY_Q, ignoreDisable);
9273 rawret = zc_getrawkey(KEY_Q, ignoreDisable);
9274 eatEntirely = false;
9275 break;
9276 case btnI:
9277 ret = zc_getkey(KEY_I, ignoreDisable);
9278 rawret = zc_getrawkey(KEY_I, ignoreDisable);
9279 eatEntirely = false;
9280 break;
9281 case btnM:
9282
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6517433 times.
6517433 if(FFCore.kb_typing_mode) return false;
9283 6517433 rawret = ret = zc_getrawkey(KEY_ESC, ignoreDisable);
9284 6517433 eatEntirely = false;
9285 6517433 break;
9286 default: //control_state[] index
9287
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100736977 times.
100736977 if(FFCore.kb_typing_mode) return false;
9288
5/6
✓ Branch 0 taken 100509247 times.
✓ Branch 1 taken 227730 times.
✓ Branch 2 taken 2164291 times.
✓ Branch 3 taken 98344956 times.
✓ Branch 4 taken 2164291 times.
✗ Branch 5 not taken.
100736977 if(!ignoreDisable && get_bit(quest_rules, qr_FIXDRUNKINPUTS) && disable_control[btn]) drunk = false;
9289
2/2
✓ Branch 0 taken 5491613 times.
✓ Branch 1 taken 95245364 times.
100736977 else if(btn<11) drunkstate = drunk_toggle_state[btn];
9290
4/4
✓ Branch 0 taken 90657940 times.
✓ Branch 1 taken 10079037 times.
✓ Branch 2 taken 1395 times.
✓ Branch 3 taken 10077642 times.
110816014 ret = control_state[btn] && (ignoreDisable || !disable_control[btn]);
9291 100736977 rawret = raw_control_state[btn];
9292 100736977 }
9293
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 107254410 times.
107254410 assert(flag);
9294
2/2
✓ Branch 0 taken 70505419 times.
✓ Branch 1 taken 36748991 times.
107254410 if(press)
9295 {
9296
2/2
✓ Branch 0 taken 10039 times.
✓ Branch 1 taken 36738952 times.
36748991 if(peek)
9297 10039 ret = rButtonPeek(ret, *flag);
9298
3/4
✓ Branch 0 taken 36738952 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 17043509 times.
✓ Branch 3 taken 19695443 times.
36738952 else if (replay_is_active() && replay_get_version() < 8) ret = rButton(ret, *flag);
9299 17043509 else ret = rButton(ret, *flag, &rawret);
9300 36748991 }
9301
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 107254410 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
107254410 if(eatEntirely && ret) control_state[btn] = false;
9302
3/4
✓ Branch 0 taken 80735722 times.
✓ Branch 1 taken 26518688 times.
✓ Branch 2 taken 80735722 times.
✗ Branch 3 not taken.
107254410 if(drunk && drunkstate) ret = !ret;
9303 107254410 return ret;
9304 107254410 }
9305
9306 391421 byte getIntBtnInput(byte intbtn, bool press, bool drunk, bool ignoreDisable, bool eatEntirely, bool peek)
9307 {
9308 391421 byte ret = 0;
9309
2/2
✓ Branch 0 taken 379392 times.
✓ Branch 1 taken 12029 times.
391421 if(intbtn & INT_BTN_A) ret |= getInput(btnA, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_A : 0;
9310
2/2
✓ Branch 0 taken 390859 times.
✓ Branch 1 taken 562 times.
391421 if(intbtn & INT_BTN_B) ret |= getInput(btnB, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_B : 0;
9311
2/2
✓ Branch 0 taken 390984 times.
✓ Branch 1 taken 437 times.
391421 if(intbtn & INT_BTN_L) ret |= getInput(btnL, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_L : 0;
9312
2/2
✓ Branch 0 taken 390984 times.
✓ Branch 1 taken 437 times.
391421 if(intbtn & INT_BTN_R) ret |= getInput(btnR, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_R : 0;
9313
2/2
✓ Branch 0 taken 390984 times.
✓ Branch 1 taken 437 times.
391421 if(intbtn & INT_BTN_EX1) ret |= getInput(btnEx1, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_EX1 : 0;
9314
2/2
✓ Branch 0 taken 390984 times.
✓ Branch 1 taken 437 times.
391421 if(intbtn & INT_BTN_EX2) ret |= getInput(btnEx2, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_EX2 : 0;
9315
2/2
✓ Branch 0 taken 390984 times.
✓ Branch 1 taken 437 times.
391421 if(intbtn & INT_BTN_EX3) ret |= getInput(btnEx3, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_EX3 : 0;
9316
2/2
✓ Branch 0 taken 390984 times.
✓ Branch 1 taken 437 times.
391421 if(intbtn & INT_BTN_EX4) ret |= getInput(btnEx4, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_EX4 : 0;
9317 391421 return ret; //No early return, to make sure all button presses are eaten that should be! -Em
9318 }
9319
9320 1114 byte checkIntBtnVal(byte intbtn, byte vals)
9321 {
9322 1114 return intbtn&vals;
9323 }
9324
9325 1281348 bool Up()
9326 {
9327 1281348 return getInput(btnUp);
9328 }
9329 77421 bool Down()
9330 {
9331 77421 return getInput(btnDown);
9332 }
9333 167324 bool Left()
9334 {
9335 167324 return getInput(btnLeft);
9336 }
9337 188659 bool Right()
9338 {
9339 188659 return getInput(btnRight);
9340 }
9341 68115 bool cAbtn()
9342 {
9343 68115 return getInput(btnA);
9344 }
9345 1255212 bool cBbtn()
9346 {
9347 1255212 return getInput(btnB);
9348 }
9349 bool cSbtn()
9350 {
9351 return getInput(btnS);
9352 }
9353 29891 bool cLbtn()
9354 {
9355 29891 return getInput(btnL);
9356 }
9357 29891 bool cRbtn()
9358 {
9359 29891 return getInput(btnR);
9360 }
9361 bool cPbtn()
9362 {
9363 return getInput(btnP);
9364 }
9365 bool cEx1btn()
9366 {
9367 return getInput(btnEx1);
9368 }
9369 bool cEx2btn()
9370 {
9371 return getInput(btnEx2);
9372 }
9373 bool cEx3btn()
9374 {
9375 return getInput(btnEx3);
9376 }
9377 bool cEx4btn()
9378 {
9379 return getInput(btnEx4);
9380 }
9381 bool AxisUp()
9382 {
9383 return getInput(btnAxisUp);
9384 }
9385 bool AxisDown()
9386 {
9387 return getInput(btnAxisDown);
9388 }
9389 bool AxisLeft()
9390 {
9391 return getInput(btnAxisLeft);
9392 }
9393 bool AxisRight()
9394 {
9395 return getInput(btnAxisRight);
9396 }
9397
9398 bool cMbtn()
9399 {
9400 return getInput(btnM);
9401 }
9402 bool cF12()
9403 {
9404 return getInput(btnF12);
9405 }
9406 bool cF11()
9407 {
9408 return getInput(btnF11);
9409 }
9410 bool cF5()
9411 {
9412 return getInput(btnF5);
9413 }
9414 bool cQ()
9415 {
9416 return getInput(btnQ);
9417 }
9418 bool cI()
9419 {
9420 return getInput(btnI);
9421 }
9422
9423 112876 bool rUp()
9424 {
9425 112876 return getInput(btnUp, true);
9426 }
9427 112804 bool rDown()
9428 {
9429 112804 return getInput(btnDown, true);
9430 }
9431 112757 bool rLeft()
9432 {
9433 112757 return getInput(btnLeft, true);
9434 }
9435 112309 bool rRight()
9436 {
9437 112309 return getInput(btnRight, true);
9438 }
9439 2482 bool rAbtn()
9440 {
9441 2482 return getInput(btnA, true);
9442 }
9443 113491 bool rBbtn()
9444 {
9445 113491 return getInput(btnB, true);
9446 }
9447 5266505 bool rSbtn()
9448 {
9449 5266505 return getInput(btnS, true);
9450 }
9451 6510614 bool rMbtn()
9452 {
9453 6510614 return getInput(btnM, true);
9454 }
9455 112109 bool rLbtn()
9456 {
9457 112109 return getInput(btnL, true);
9458 }
9459 112106 bool rRbtn()
9460 {
9461 112106 return getInput(btnR, true);
9462 }
9463 5182404 bool rPbtn()
9464 {
9465 5182404 return getInput(btnP, true);
9466 }
9467 bool rEx1btn()
9468 {
9469 return getInput(btnEx1, true);
9470 }
9471 bool rEx2btn()
9472 {
9473 return getInput(btnEx2, true);
9474 }
9475 122985 bool rEx3btn()
9476 {
9477 122985 return getInput(btnEx3, true);
9478 }
9479 122985 bool rEx4btn()
9480 {
9481 122985 return getInput(btnEx4, true);
9482 }
9483 bool rAxisUp()
9484 {
9485 return getInput(btnAxisUp, true);
9486 }
9487 bool rAxisDown()
9488 {
9489 return getInput(btnAxisDown, true);
9490 }
9491 bool rAxisLeft()
9492 {
9493 return getInput(btnAxisLeft, true);
9494 }
9495 bool rAxisRight()
9496 {
9497 return getInput(btnAxisRight, true);
9498 }
9499
9500 bool rF11()
9501 {
9502 return getInput(btnF11, true);
9503 }
9504 bool rQ()
9505 {
9506 return getInput(btnQ, true);
9507 }
9508 bool rI()
9509 {
9510 return getInput(btnI, true);
9511 }
9512
9513 13317771 bool DrunkUp()
9514 {
9515 13317771 return getInput(btnUp, false, true);
9516 }
9517 12417217 bool DrunkDown()
9518 {
9519 12417217 return getInput(btnDown, false, true);
9520 }
9521 7866450 bool DrunkLeft()
9522 {
9523 7866450 return getInput(btnLeft, false, true);
9524 }
9525 6829749 bool DrunkRight()
9526 {
9527 6829749 return getInput(btnRight, false, true);
9528 }
9529 5759186 bool DrunkcAbtn()
9530 {
9531 5759186 return getInput(btnA, false, true);
9532 }
9533 5722928 bool DrunkcBbtn()
9534 {
9535 5722928 return getInput(btnB, false, true);
9536 }
9537 5152193 bool DrunkcEx1btn()
9538 {
9539 5152193 return getInput(btnEx1, false, true);
9540 }
9541 5152213 bool DrunkcEx2btn()
9542 {
9543 5152213 return getInput(btnEx2, false, true);
9544 }
9545 bool DrunkcSbtn()
9546 {
9547 return getInput(btnS, false, true);
9548 }
9549 bool DrunkcMbtn()
9550 {
9551 return getInput(btnM, false, true);
9552 }
9553 bool DrunkcLbtn()
9554 {
9555 return getInput(btnL, false, true);
9556 }
9557 bool DrunkcRbtn()
9558 {
9559 return getInput(btnR, false, true);
9560 }
9561 bool DrunkcPbtn()
9562 {
9563 return getInput(btnP, false, true);
9564 }
9565
9566 bool DrunkrUp()
9567 {
9568 return getInput(btnUp, true, true);
9569 }
9570 bool DrunkrDown()
9571 {
9572 return getInput(btnDown, true, true);
9573 }
9574 bool DrunkrLeft()
9575 {
9576 return getInput(btnLeft, true, true);
9577 }
9578 bool DrunkrRight()
9579 {
9580 return getInput(btnRight, true, true);
9581 }
9582 4368002 bool DrunkrAbtn()
9583 {
9584 4368002 return getInput(btnA, true, true);
9585 }
9586 4328323 bool DrunkrBbtn()
9587 {
9588 4328323 return getInput(btnB, true, true);
9589 }
9590 71669 bool DrunkrEx1btn()
9591 {
9592 71669 return getInput(btnEx1, true, true);
9593 }
9594 71662 bool DrunkrEx2btn()
9595 {
9596 71662 return getInput(btnEx2, true, true);
9597 }
9598 bool DrunkrEx3btn()
9599 {
9600 return getInput(btnEx3, true, true);
9601 }
9602 bool DrunkrEx4btn()
9603 {
9604 return getInput(btnEx4, true, true);
9605 }
9606 bool DrunkrSbtn()
9607 {
9608 return getInput(btnS, true, true);
9609 }
9610 bool DrunkrMbtn()
9611 {
9612 return getInput(btnM, true, true);
9613 }
9614 4832892 bool DrunkrLbtn()
9615 {
9616 4832892 return getInput(btnL, true, true);
9617 }
9618 4830254 bool DrunkrRbtn()
9619 {
9620 4830254 return getInput(btnR, true, true);
9621 }
9622 bool DrunkrPbtn()
9623 {
9624 return getInput(btnP, true, true);
9625 }
9626
9627 6819 void eat_buttons()
9628 {
9629 6819 getInput(btnA, true, false, true);
9630 6819 getInput(btnB, true, false, true);
9631 6819 getInput(btnS, true, false, true);
9632 6819 getInput(btnM, true, false, true);
9633 6819 getInput(btnL, true, false, true);
9634 6819 getInput(btnR, true, false, true);
9635 6819 getInput(btnP, true, false, true);
9636 6819 getInput(btnEx1, true, false, true);
9637 6819 getInput(btnEx2, true, false, true);
9638 6819 getInput(btnEx3, true, false, true);
9639 6819 getInput(btnEx4, true, false, true);
9640 6819 }
9641
9642 // Is true for the _first frame_ of a key press.
9643 // But! it is possible that a script manually sets the value of KeyPress,
9644 // in which case it will be restored to the "true" value based on `key_current_frame`
9645 // and `key_previous_frame` on the next frame.
9646 14 bool zc_readkey(int32_t k, bool ignoreDisable)
9647 {
9648
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(ignoreDisable) return KeyPress[k];
9649
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 switch(k)
9650 {
9651 case KEY_F7:
9652 case KEY_F8:
9653 case KEY_F9:
9654 return KeyPress[k];
9655
9656 default:
9657
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 1 times.
14 return KeyPress[k] && !disabledKeys[k];
9658 }
9659 14 }
9660
9661 // Is true for _every frame_ a key is held down.
9662 // But! it is possible that a script manually sets the value of KeyInput,
9663 // in which case it will be restored to the "true" value based on `key_current_frame`
9664 // on the next frame.
9665 bool zc_getkey(int32_t k, bool ignoreDisable)
9666 {
9667 if(ignoreDisable) return KeyInput[k];
9668 switch(k)
9669 {
9670 case KEY_F7:
9671 case KEY_F8:
9672 case KEY_F9:
9673 return KeyInput[k];
9674
9675 default:
9676 return KeyInput[k] && !disabledKeys[k];
9677 }
9678 }
9679
9680 // Reads (and then clears) the current frame key state directly.
9681 // Scripts can also modify `key_current_frame`.
9682 125 bool zc_readrawkey(int32_t k, bool ignoreDisable)
9683 {
9684
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 123 times.
125 if(zc_getrawkey(k, ignoreDisable))
9685 {
9686 2 _key[k]=key[k]=key_current_frame[k]=0;
9687 2 return true;
9688 }
9689 123 _key[k]=key[k]=key_current_frame[k]=0;
9690 123 return false;
9691 125 }
9692
9693 // Reads the current frame key state directly.
9694 // Scripts can also modify `key_current_frame`.
9695 43497761 bool zc_getrawkey(int32_t k, bool ignoreDisable)
9696 {
9697
2/2
✓ Branch 0 taken 36987119 times.
✓ Branch 1 taken 6510642 times.
43497761 if(ignoreDisable) return key_current_frame[k];
9698
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6510642 times.
6510642 switch(k)
9699 {
9700 case KEY_F7:
9701 case KEY_F8:
9702 case KEY_F9:
9703 return key_current_frame[k];
9704
9705 default:
9706
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6510642 times.
6510642 return key_current_frame[k] && !disabledKeys[k];
9707 }
9708 43497761 }
9709
9710 // Only used for a handful of keys, like tilde and Function keys.
9711 // This state is never read within the game.
9712 // It exists so that all keyboard input still functions during replay,
9713 // without inadvertently doing things like toggling throttling if the player
9714 // presses ~
9715 13021293 bool zc_get_system_key(int32_t k)
9716 {
9717 13021293 return key_system[k];
9718 }
9719
9720 // True for the _first_ frame of a key press.
9721 58595526 bool zc_read_system_key(int32_t k)
9722 {
9723 58595526 return key_system_press[k];
9724 }
9725
9726 826847978 bool is_system_key(int32_t k)
9727 {
9728
2/2
✓ Branch 0 taken 768252452 times.
✓ Branch 1 taken 58595526 times.
826847978 switch (k)
9729 {
9730 case KEY_BACKQUOTE:
9731 case KEY_CLOSEBRACE:
9732 case KEY_END:
9733 case KEY_HOME:
9734 case KEY_OPENBRACE:
9735 case KEY_PGDN:
9736 case KEY_PGUP:
9737 case KEY_TAB:
9738 case KEY_TILDE:
9739 58595526 return true;
9740 }
9741 768252452 return is_Fkey(k);
9742 826847978 }
9743
9744 6510614 void update_system_keys()
9745 {
9746
2/2
✓ Branch 0 taken 826847978 times.
✓ Branch 1 taken 6510614 times.
833358592 for (int32_t q = 0; q < 127; ++q)
9747 {
9748
2/2
✓ Branch 0 taken 136722894 times.
✓ Branch 1 taken 690125084 times.
826847978 if (!is_system_key(q))
9749 690125084 continue;
9750
9751 136722894 key_system[q] = key[q];
9752
1/2
✓ Branch 0 taken 136722894 times.
✗ Branch 1 not taken.
136722894 key_system_press[q] = key_system[q] && !key_system_previous[q];
9753 136722894 key_system_previous[q] = key_system[q];
9754 136722894 }
9755 6510614 }
9756
9757 7628080 void update_keys()
9758 {
9759
2/2
✓ Branch 0 taken 968766160 times.
✓ Branch 1 taken 7628080 times.
976394240 for (int32_t q = 0; q < 127; ++q)
9760 {
9761 // When replaying, replay.cpp takes care of updating `key_current_frame`.
9762
1/2
✓ Branch 0 taken 968766160 times.
✗ Branch 1 not taken.
968766160 if (!replay_is_replaying())
9763 key_current_frame[q] = key[q];
9764
9765
2/2
✓ Branch 0 taken 961653306 times.
✓ Branch 1 taken 7112854 times.
968766160 KeyPress[q] = key_current_frame[q] && !key_previous_frame[q];
9766 968766160 KeyInput[q] = key_current_frame[q];
9767 968766160 key_previous_frame[q] = key_current_frame[q];
9768 968766160 }
9769 7628080 }
9770
9771 bool zc_disablekey(int32_t k, bool val)
9772 {
9773 switch(k)
9774 {
9775 case KEY_F7:
9776 case KEY_F8:
9777 case KEY_F9:
9778 return false;
9779
9780 default:
9781 disabledKeys[k] = val;
9782 return true;
9783 }
9784 }
9785
9786 void zc_putpixel(int32_t layer, int32_t x, int32_t y, int32_t cset, int32_t color, int32_t timer)
9787 {
9788 timer=timer;
9789 particles.add(new particle(zfix(x), zfix(y), layer, cset, color));
9790 }
9791
9792 // these are here so that copy_dialog won't choke when compiling zelda
9793 int32_t d_alltriggerbutton_proc(int32_t, DIALOG*, int32_t)
9794 {
9795 return D_O_K;
9796 }
9797
9798 int32_t d_comboa_radio_proc(int32_t, DIALOG*, int32_t)
9799 {
9800 return D_O_K;
9801 }
9802
9803 int32_t d_comboabutton_proc(int32_t, DIALOG*, int32_t)
9804 {
9805 return D_O_K;
9806 }
9807
9808 int32_t d_ssdn_btn_proc(int32_t, DIALOG*, int32_t)
9809 {
9810 return D_O_K;
9811 }
9812
9813 int32_t d_ssdn_btn2_proc(int32_t, DIALOG*, int32_t)
9814 {
9815 return D_O_K;
9816 }
9817
9818 int32_t d_ssdn_btn3_proc(int32_t, DIALOG*, int32_t)
9819 {
9820 return D_O_K;
9821 }
9822
9823 int32_t d_ssdn_btn4_proc(int32_t, DIALOG*, int32_t)
9824 {
9825 return D_O_K;
9826 }
9827
9828 int32_t d_sslt_btn_proc(int32_t, DIALOG*, int32_t)
9829 {
9830 return D_O_K;
9831 }
9832
9833 int32_t d_sslt_btn2_proc(int32_t, DIALOG*, int32_t)
9834 {
9835 return D_O_K;
9836 }
9837
9838 int32_t d_sslt_btn3_proc(int32_t, DIALOG*, int32_t)
9839 {
9840 return D_O_K;
9841 }
9842
9843 int32_t d_sslt_btn4_proc(int32_t, DIALOG*, int32_t)
9844 {
9845 return D_O_K;
9846 }
9847
9848 int32_t d_ssrt_btn_proc(int32_t, DIALOG*, int32_t)
9849 {
9850 return D_O_K;
9851 }
9852
9853 int32_t d_ssrt_btn2_proc(int32_t, DIALOG*, int32_t)
9854 {
9855 return D_O_K;
9856 }
9857
9858 int32_t d_ssrt_btn3_proc(int32_t, DIALOG*, int32_t)
9859 {
9860 return D_O_K;
9861 }
9862
9863 int32_t d_ssrt_btn4_proc(int32_t, DIALOG*, int32_t)
9864 {
9865 return D_O_K;
9866 }
9867
9868 int32_t d_ssup_btn_proc(int32_t, DIALOG*, int32_t)
9869 {
9870 return D_O_K;
9871 }
9872
9873 int32_t d_ssup_btn2_proc(int32_t, DIALOG*, int32_t)
9874 {
9875 return D_O_K;
9876 }
9877
9878 int32_t d_ssup_btn3_proc(int32_t, DIALOG*, int32_t)
9879 {
9880 return D_O_K;
9881 }
9882
9883 int32_t d_ssup_btn4_proc(int32_t, DIALOG*, int32_t)
9884 {
9885 return D_O_K;
9886 }
9887
9888 int32_t d_tri_edit_proc(int32_t, DIALOG*, int32_t)
9889 {
9890 return D_O_K;
9891 }
9892
9893 int32_t d_triggerbutton_proc(int32_t, DIALOG*, int32_t)
9894 {
9895 return D_O_K;
9896 }
9897
9898 /*** end of zc_sys.cc ***/
9899
9900